Skip to content

Commit d73ea5f

Browse files
authored
Fix stakeholder Details view on mobile (#2689)
1 parent d40b260 commit d73ea5f

2 files changed

Lines changed: 17 additions & 45 deletions

File tree

client/src/components/FoodSeeker/SearchResults/StakeholderDetails/StakeholderDetails.jsx

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import {
4040
useSelectedOrganization,
4141
useUserCoordinates,
4242
useWidget,
43-
usePosition,
4443
} from "../../../../appReducer";
4544
import { useToasterContext } from "../../../../contexts/toasterContext";
4645
import SEO from "../../../SEO";
@@ -96,8 +95,6 @@ const StakeholderDetails = ({ onBackClick, isDesktop }) => {
9695
const navigate = useNavigate();
9796
const { setToast } = useToasterContext();
9897
const { tenantTimeZone } = useSiteContext();
99-
const position = usePosition();
100-
const [paddingBottom, setPaddingBottom] = useState(30);
10198

10299
const foodTypes = useMemo(() => {
103100
return (
@@ -113,32 +110,6 @@ const StakeholderDetails = ({ onBackClick, isDesktop }) => {
113110
);
114111
}, [selectedOrganization]);
115112

116-
useEffect(() => {
117-
const windowHeight = window.innerHeight / 100;
118-
if (
119-
position.y === (100 / window.innerHeight) * 54 * windowHeight ||
120-
position.y === 0 * windowHeight
121-
) {
122-
setPaddingBottom(200);
123-
} else if (position.y === 17 * windowHeight) {
124-
setPaddingBottom(300);
125-
}
126-
}, [position]);
127-
128-
// USE EFFECT BASED ON THIS FUNCTION IN Mobile.js
129-
// const handleStop = (e, ui) => {
130-
// const windowHeight = window.innerHeight / 100;
131-
// let newY;
132-
// if (ui.y < 20 * windowHeight) {
133-
// newY = hasAdvancedFilterFeatureFlag ? (100 / window.innerHeight) * 60 : 0;
134-
// } else if (ui.y > 20 * windowHeight && ui.y < 40 * windowHeight) {
135-
// newY = 17;
136-
// } else if (ui.y > 40 * windowHeight) {
137-
// newY = 54;
138-
// }
139-
// setPosition({ x: 0, y: newY * windowHeight });
140-
// };
141-
142113
useEffect(() => {
143114
if (selectedOrganization?.id) {
144115
analytics.postEvent("viewDetail", {

client/src/components/FoodSeeker/SearchResults/layouts/Mobile.jsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
import { Box, Grid, Stack } from "@mui/material";
1+
import { Box, Stack } from "@mui/material";
22
import { useEffect, useState } from "react";
33
import Draggable from "react-draggable";
44
import { useFilterPanel } from "appReducer";
55
import AttributionInfo from "../AttributionInfo";
66
import { useAppDispatch } from "../../../../appReducer";
77
import useFeatureFlag from "hooks/useFeatureFlag";
88

9-
const overlay = {
9+
const getOverlayStyle = (positionY) => ({
1010
position: "absolute",
1111
width: "100%",
12-
height: "100%",
12+
top: 0,
13+
bottom: `${positionY}px`,
1314
backgroundColor: "transparent",
1415
zIndex: 1000,
1516
borderRadius: "10px",
16-
};
17+
display: "flex",
18+
flexDirection: "column",
19+
overflow: "hidden",
20+
});
1721

1822
const MobileLayout = ({ filters, map, list, showList }) => {
1923
const filterPanelOpen = useFilterPanel();
@@ -25,14 +29,6 @@ const MobileLayout = ({ filters, map, list, showList }) => {
2529
y: initialY * (window.innerHeight / 100),
2630
});
2731

28-
// disable body scroll
29-
useEffect(() => {
30-
window.scrollTo({
31-
top: 0,
32-
});
33-
document.body.style.overflow = "hidden";
34-
}, []);
35-
3632
useEffect(() => {
3733
dispatch({ type: "POSITION", position: position });
3834
}, [position, dispatch]);
@@ -48,6 +44,10 @@ const MobileLayout = ({ filters, map, list, showList }) => {
4844
setPosition({ x: 0, y: newY * (window.innerHeight / 100) });
4945
}, [showList, filterPanelOpen, hasAdvancedFilterFeatureFlag]);
5046

47+
const handleDrag = (e, ui) => {
48+
setPosition({ x: 0, y: ui.y });
49+
};
50+
5151
const handleStop = (e, ui) => {
5252
const windowHeight = window.innerHeight / 100;
5353
const minY = hasAdvancedFilterFeatureFlag
@@ -75,7 +75,7 @@ const MobileLayout = ({ filters, map, list, showList }) => {
7575

7676
return (
7777
<>
78-
{filters}
78+
<Box>{filters}</Box>
7979
<Box
8080
sx={{
8181
height: window.innerHeight,
@@ -100,6 +100,7 @@ const MobileLayout = ({ filters, map, list, showList }) => {
100100
{list && (
101101
<Draggable
102102
position={position}
103+
onDrag={handleDrag}
103104
onStop={handleStop}
104105
handle=".handle"
105106
bounds={{ top: 0, bottom: minY * (window.innerHeight / 100) }}
@@ -111,8 +112,7 @@ const MobileLayout = ({ filters, map, list, showList }) => {
111112
backgroundColor: "white",
112113
}}
113114
>
114-
<Box sx={overlay}>
115-
<Grid container spacing={0}></Grid>
115+
<Box sx={getOverlayStyle(position.y)}>
116116
<Box
117117
sx={{
118118
width: "100vw",
@@ -143,8 +143,9 @@ const MobileLayout = ({ filters, map, list, showList }) => {
143143
<Box
144144
sx={{
145145
backgroundColor: "white",
146-
height: "100%",
146+
flex: 1,
147147
width: "100vw",
148+
overflow: "hidden",
148149
}}
149150
>
150151
{list}

0 commit comments

Comments
 (0)