[Bug]: Closed sheets (index={-1}) peek above the bottom edge on Android edge-to-edge — initial position uses Dimensions.get('window').height
Version
v5
Reanimated Version
v3
Gesture Handler Version
v2
Platforms
Android
What happened?
Note on versions: the dropdowns above have no option for it, but this is with @gorhom/bottom-sheet 5.2.14 and react-native-reanimated 4.1.7 (react-native 0.81.5, New Architecture, edge-to-edge enforced, targetSdk 36).
Several inline (non-modal) <BottomSheet index={-1} /> mounted permanently on a screen should be fully off-screen while closed. On Android edge-to-edge, their handles peek above the bottom edge of the screen by exactly the status-bar height (~24dp), stacked on top of each other, and each sheet can be dragged open from its peeking handle. Same code is correct on iOS, and was correct on Android pre-edge-to-edge. Likely the root cause behind #329 and related to #2680.
Root cause (verified with enableLogging measurements):
BottomSheet.tsx (~line 218) initializes the position with the window height:
const animatedPosition = useSharedValue(Dimensions.get('window').height);On the affected device (Samsung, 1080×2400, density 2.8125):
BottomSheetHostingContainer::handleLayoutEvent→ container height = 853.33dp (true full-screen container)Dimensions.get('window').height= 829.16dp (Samsung reportswindowexcluding the status bar even in edge-to-edge)- Difference = 24.17dp = StatusBar.currentHeight = exactly the visible peek.
The correct closed position (closedDetentPosition = containerHeight in useAnimatedDetents) is computed later — but a sheet that stays at index={-1} is never animated, so the stale initial value is never corrected.
Fix suggestion: initialize with Dimensions.get('screen').height (always ≥ container height; window === screen on iOS so no change there). Alternatively/in addition: re-sync animatedPosition to closedDetentPosition when detents are (re)computed while the sheet is CLOSED — that would also cover rotation/resize and the #2680 family. We currently ship the one-line patch-package fix with no observed regressions.
Reproduction steps
- React Native 0.81 app with edge-to-edge (targetSdk 36), New Architecture
- Mount an inline
<BottomSheet index={-1} snapPoints={['60%']} enableDynamicSizing={false} />(several of them makes it obvious) on a full-screen view - Run on an Android device where
Dimensions.get('window').height < Dimensions.get('screen').height(e.g. many Samsung models — this is the device-specific trigger; on devices where window === screen the bug is invisible) - Observe the sheet handle peeking above the bottom edge by the status-bar height; drag it up to open the supposedly closed sheet
Reproduction sample
https://snack.expo.dev/@gorhom/bottom-sheet---issue-reproduction-template
Relevant log output
# device: Samsung 1080x2400, density 2.8125 → screen = 853.33dp, StatusBar.currentHeight = 24.17dp
[BottomSheetHostingContainer::handleLayoutEvent] height:853.3333129882812
[BottomSheetHandleContainer::handleContainerLayout] height:24.177778244018555
[BottomSheetView::handleLayout] height:471.1111145019531
# Dimensions.get('window').height on this device = 829.16dp
# → initial animatedPosition = 829.16 while closed position should be 853.33
# → handle rests 24.17dp above the bottom edgeSource: gorhom/react-native-bottom-sheet