1- import { Box , Grid , Stack } from "@mui/material" ;
1+ import { Box , Stack } from "@mui/material" ;
22import { useEffect , useState } from "react" ;
33import Draggable from "react-draggable" ;
44import { useFilterPanel } from "appReducer" ;
55import AttributionInfo from "../AttributionInfo" ;
66import { useAppDispatch } from "../../../../appReducer" ;
77import 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
1822const 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