Skip to content

Commit

Permalink
fix: prevent closing when sheet is out of screen (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhom committed Mar 4, 2021
1 parent a47c300 commit 0aa88ad
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
? safeContainerHeight
: snapPoints[currentIndexRef.current];
}, [snapPoints, animateOnMount, safeContainerHeight]);
const currentPositionRef = useRef<number>(initialPosition);
//#endregion

//#region gestures
Expand Down Expand Up @@ -369,7 +370,11 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
);
const handleClose = useCallback(() => {
const currentIndexValue = currentIndexRef.current;
if (currentIndexValue === -1 || isClosing.current) {
if (
currentIndexValue === -1 ||
isClosing.current ||
currentPositionRef.current === safeContainerHeight
) {
return;
}
isClosing.current = true;
Expand Down Expand Up @@ -565,6 +570,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
});

currentIndexRef.current = currentPositionIndex;
currentPositionRef.current = args[0];
refreshUIElements();
handleOnChange(currentPositionIndex);
}),
Expand Down

0 comments on commit 0aa88ad

Please sign in to comment.