Skip to content

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

@laijoann

Description

@laijoann

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.

const {
containerHeight,
containerOffset,
mountSheet,
unmountSheet,
willUnmountSheet,
} = useBottomSheetModalInternal();

const animatedContainerOffset = useSharedValue(INITIAL_CONTAINER_OFFSET);

Reproduction steps

  • Pass a value into containerOffset when using the BottomSheetModal
  • Trigger a keyboard open by focusing on the BottomSheetTextInput
  • Note the missing offset 😢

Reproduction sample

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

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions