gorhom / react-native-bottom-sheet

A performant interactive bottom sheet with fully configurable options 🚀
https://gorhom.dev/react-native-bottom-sheet/
MIT License
7.08k stars 777 forks source link

[Bug]: `containerOffset` value ignored when using `BottomSheetModal` #2028

Open laijoann opened 1 week ago

laijoann commented 1 week ago

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

iOS, Android

What happened?

Expectation:

When using BottomSheetModal with the containerOffset prop, I expected that offset to.. well, offset the container. E.g. if I pass in a value like useSharedValue({top: 0, bottom: 12, left: 0, right: 0}) and trigger the keyboard open, I'd expect the sheet to be offset from the keyboard by 12.

Reality:

No offsets are applied. In taking a look at BottomSheetModal, I see that the containerOffset value is pulled from useBottomSheetModalInternal. Further tracking that down, it appears BottomSheetModalProviderWrapper sets the animatedContainerOffset directly as useSharedValue(INITIAL_CONTAINER_OFFSET) without factoring in the user provided containerOffset.

https://github.com/gorhom/react-native-bottom-sheet/blob/398e7114d7577c37361e6e24c9180b13de2c08ed/src/components/bottomSheetModal/BottomSheetModal.tsx#L69-L75 https://github.com/gorhom/react-native-bottom-sheet/blob/398e7114d7577c37361e6e24c9180b13de2c08ed/src/components/bottomSheetModalProvider/BottomSheetModalProvider.tsx#L28

Reproduction steps

Reproduction sample

https://snack.expo.dev/@expojojo/bottom-sheet---issue-reproduction-template

Relevant log output

No response