Skip to content

[Bug]: TextInput shrink causes bottom sheet to "blink" on Android #2324

@pakerwreah

Description

@pakerwreah

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

Android

What happened?

I have a bottom sheet with enableDynamicSizing and a multiline TextInput.
If I press "enter", the text input grows and so the bottom sheet. So far so good.

If I delete a line, the bottom sheet briefly snaps to animatedIndex -1 and immediately goest back to 0.

That causes view to "blink" because of this code from BottomSheetBody.tsx:

const containerAnimatedStyle = useAnimatedStyle(
    () => ({
      opacity: Platform.OS === 'android' && animatedIndex.get() === -1 ? 0 : 1,

If I change that condition to 'ios', the same "blinking" issue happens on iPhone.

I don't know what was the motivation for that specific tweak on Android, but I don't think animatedIndex should be snapping to -1 out of the blue when resizing the content.

Reproduction steps

  • Create a simple bottom sheet with enableDynamicSizing and a multiline TextInput as child of BottomSheetView.
  • Press "enter" a few times to make it grow bigger.
  • Press "backspace" to delete a line
  • Notice that animatedIndex snaps to -1 and immediately reverts to 0
  • Do that on Android and verify that the bottom sheet "blinks" every time you delete a line.

Relevant Packages:

"expo": "^53.0.11",
"react": "^19.0.0",
"react-native": "^0.79.3",
"react-native-gesture-handler": "^2.24.0",
"react-native-reanimated": "^3.18.0",
"@gorhom/bottom-sheet": "^5.1.6",

Reproduction sample

Sorry, I was not able to make the input grow in snack.expo.dev for some reason.

Relevant log output

 LOG  {"category": "layout", "component": "BottomSheetView", "method": "handleLayout", "params": {"height": 113.33332824707031}}
 LOG  {"category": "layout", "component": "BottomSheetView", "method": "handleLayout", "params": {"height": 129.6666717529297}}
 LOG  {"category": "layout", "component": "BottomSheetView", "method": "handleLayout", "params": {"height": 146}}
 LOG  {"category": "layout", "component": "BottomSheetView", "method": "handleLayout", "params": {"height": 129.6666717529297}}
 LOG  animatedIndex -1
 LOG  animatedIndex 0
 LOG  {"category": "layout", "component": "BottomSheetView", "method": "handleLayout", "params": {"height": 113.33332824707031}}
 LOG  animatedIndex -1
 LOG  animatedIndex 0
 LOG  {"category": "layout", "component": "BottomSheetView", "method": "handleLayout", "params": {"height": 97}}
 LOG  animatedIndex -1
 LOG  animatedIndex 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions