Skip to content

Commit

Permalink
Fix stakeholder preview getting cut off (#2113)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanapotski authored May 21, 2024
1 parent 618c47d commit f639ee0
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/src/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function AppWrapper() {
backgroundColor: "#fff",
margin: "0",
height: "100%",
overflowX: "hidden",
overflow: "hidden",
}}
>
<Header />
Expand Down
18 changes: 17 additions & 1 deletion client/src/appReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ function isListPanelVisibleReducer(state, action) {
}
}

function position(state, action) {
switch (action.type) {
case "POSITION":
return action.position; // Toggle the state
default:
return state;
}
}


export function appReducer(state, action) {
return {
Expand Down Expand Up @@ -158,6 +167,7 @@ export function appReducer(state, action) {
),
listPanel: listPanelReducer(state.listPanel, action),
isListPanelVisible: isListPanelVisibleReducer(state.isListPanelVisible, action),
position: position(state.position, action)
};
}

Expand All @@ -174,7 +184,8 @@ export function getInitialState() {
openTimeFilter: { radio: "Show All", day: "", time: "" },
noKnownEligibilityRequirementsFilter: false,
listPanel: true,
isListPanelVisible: false
isListPanelVisible: false,
position: '0'
};
}

Expand Down Expand Up @@ -268,3 +279,8 @@ export function useIsListPanelVisible() {
return isListPanelVisible;
}

export function usePosition() {
const { position } = useAppState();
return position;
}

Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const ResultsMap = (
const filterPanelLeftPostion = isFilterPanelOpen ? 340 : 0;

return (
<div style={{ position: "relative", height: "100%" }}>
<div style={{ position: "relative", height: "100%", width: "100%" }}>
<Map
ref={mapRef}
{...viewport}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
useSelectedOrganization,
useUserCoordinates,
useWidget,
usePosition
} from "../../../../appReducer";
import { useToasterContext } from "../../../../contexts/toasterContext";
import SEO from "../../../SEO";
Expand Down Expand Up @@ -88,6 +89,34 @@ const StakeholderDetails = ({ onBackClick, isDesktop }) => {
const navigate = useNavigate();
const { setToast } = useToasterContext();
const { tenantTimeZone } = useSiteContext();
const position = usePosition();
const [paddingBottom, setPaddingBottom] = useState(30)

useEffect(()=> {
const windowHeight = window.innerHeight / 100;
if(position.y === (100 / window.innerHeight * 60) * windowHeight || position.y === 5 * windowHeight){
setPaddingBottom(300)
}
else if(position.y === 25 * windowHeight){
setPaddingBottom(window.innerHeight / 1.3)
}

},[position])

// USE EFFECT BASED ON THIS FUNCTION IN Mobile.js
// const handleStop = (e, ui) => {
// const windowHeight = window.innerHeight / 100;
// let newY;
// if (ui.y < 20 * windowHeight) {
// newY = hasAdvancedFilterFeatureFlag ? (100 / window.innerHeight) * 60 : 5;
// } else if (ui.y > 20 * windowHeight && ui.y < 40 * windowHeight) {
// newY = 25;
// } else if (ui.y > 40 * windowHeight) {
// newY = 57;
// }
// setPosition({ x: 0, y: newY * windowHeight });
// };


useEffect(() => {
if (selectedOrganization?.id) {
Expand Down Expand Up @@ -330,7 +359,8 @@ const StakeholderDetails = ({ onBackClick, isDesktop }) => {
sx={{
minHeight: "6rem",
overflowY: "scroll",
padding: isDesktop ? "38px 35px 0 65px" : "0 23px 0",
padding: isDesktop ? "38px 35px 0 65px" : "38px 23px 0",
paddingBottom: isDesktop ? "0" : `${paddingBottom}px`,
}}
>
<Grid2 xs={2}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useFilterPanel } from "appReducer";
import AttributionInfo from "../AttributionInfo";
import {
useIsListPanelVisible,
useAppDispatch
} from '../../../../appReducer'
import useFeatureFlag from "hooks/useFeatureFlag";

Expand All @@ -21,6 +22,7 @@ const MobileLayout = ({ filters, map, list, showList }) => {
const filterPanelOpen = useFilterPanel();
const initialY = showList ? 5 : 57;
const hasAdvancedFilterFeatureFlag = useFeatureFlag("advancedFilter");
const dispatch = useAppDispatch();

const [position, setPosition] = useState({
x: 0,
Expand All @@ -38,6 +40,12 @@ const MobileLayout = ({ filters, map, list, showList }) => {
})
}, [isListPanelVisible])


useEffect(() => {
dispatch({ type: "POSITION", position: position });
}, [position])


useEffect(() => {
let newY;
if (filterPanelOpen) {
Expand Down Expand Up @@ -73,7 +81,6 @@ const MobileLayout = ({ filters, map, list, showList }) => {
height: window.innerHeight,
display: "flex",
flexDirection: "column",
overflow: "hidden",
position: "relative",
}}
>
Expand Down

0 comments on commit f639ee0

Please sign in to comment.