-
-
Notifications
You must be signed in to change notification settings - Fork 927
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Version
v5
Reanimated Version
v3
Gesture Handler Version
v2
Platforms
Android, iOS
What happened?
When you rotate your screen (from landscape to portait).
Video of the issue:
Screen.Recording.2025-12-08.at.12.00.28.mov
The patch package that fixes this issue:
This patch package fixes the issue by reacting to the contaInerHeight. Only when the bottom sheet is closed, we want to keep it closed by updating the `animatedPosition` to the new screen height.
diff --git a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx
index 6748c93..bb6e064 100644
--- a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx
+++ b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx
@@ -1746,6 +1746,23 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
[_providedAnimatedPosition, topInset]
);
+ /** Reset position of Bottom Sheet during screen rotate */
+ useAnimatedReaction(
+ () => animatedLayoutState.value.containerHeight,
+ (newHeight, previousHeight) => {
+ if (newHeight === previousHeight) {
+ return;
+ }
+ if (!previousHeight || animatedPosition.value < previousHeight) {
+ // Do not reset position while bottom sheet is open
+ return;
+ }
+
+ animatedPosition.value = newHeight
+ },
+ [animatedLayoutState]
+ );
+
/**
* sets provided animated index
*/
Related issue: #516
Reproduction repo: https://github.com/bastiaanv/BottomSheetScreenRotate
Reproduction steps
- Clean repo init
- Install dependencies:
- npm i @gorhom/bottom-sheet react-native-reanimated react-native-worklets react-native-gesture-handler
- Follow getting started reanimated & gesture handler
- Add BottomSheet to App.tsx (I disabled dynamic sizing for this example)
- Start the app in landscape mode
- Then rotate to portrait mode and see the bottom sheet opening
Reproduction sample
https://snack.expo.dev/@bastiaanv/bottom-sheet---issue-screen-rotate-opens-bottom-sheet
Relevant log output
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working