gorhom / react-native-bottom-sheet

A performant interactive bottom sheet with fully configurable options 🚀
https://ui.gorhom.dev/components/bottom-sheet
MIT License
6.59k stars 734 forks source link

[v4] IOS: Closing Keyboard crashes if BottomSheetTextInput is inside of BottomSheetFlatlist or BottomSheetScrollView #1509

Open motudev opened 11 months ago

motudev commented 11 months ago

Bug

On IOS, when closing the keyboard of a BottomSheetTextInput at the bottom of a BottomSheetFlatlist the app crashes and closes. Rarely the keyboard just closes and acts as it is supposed to.

I already did some digging and if I comment out the line in

src/components/bottomSheet/BottomSheet.tsx line 1461 (not 1462)

weirdly the flatlist is not animated anymore but also does not crash anymore. I think there is something triggered in the background which I am not aware of, which is why I am submitting this.

https://github.com/gorhom/react-native-bottom-sheet/assets/71296097/e8d5b1e7-a747-4c07-b4c7-f0fc6959fbf5

Environment info

Library Version
@gorhom/bottom-sheet 4.5.0
react-native 0.72.4
react-native-reanimated 3.5.0
react-native-gesture-handler 2.12.1

Steps To Reproduce

  1. Open the app
  2. Scroll to the bottom of the Flatlist
  3. open the keyboard by selecting the textinput that is the last one you can see
  4. close it by pressing enter
  5. App crashes

Describe what you expected to happen:

  1. The Keyboard closes and restores the bottomsheet to its former state

Reproducible sample code

https://github.com/motudev/bottomsheet-example

thdeptrai commented 11 months ago

same issue

gorhom commented 11 months ago

looking into this issue at the moment

gorhom commented 11 months ago

I tried to repo the issue, but it did not crash :\

@motudev, @thdeptrai could you retest on the latest version and let me know ?

motudev commented 11 months ago

I tried this on latest release(updated the repo i provided accordingly) it still crashes.

Maybe the stacktrace will help. stacktrace.txt

motudev commented 10 months ago

Update:

Just if anyone happens to have the same Behaviour -> we "fixed" our problem by using a plain Flatlist or ScrollView instead of the BottomSheetFlatlist and the BottomSheetScrollView.

Obviouslsy you are missing out on some of the Bottomsheet gestures if you do that, but it was a viable solution for us, because we do not need those gestures in the components where we have this setup

ivoneug commented 9 months ago

I'm also experiencing the same issue in release build only. @gorhom do you have any plans to fix this?

mo6zes commented 9 months ago

Same here

mo6zes commented 9 months ago

@gorhom I can reproduce consistently with the following steps:

In a bottomSheetModal > bottomSheetScrollView > bottomSheetTextInput:

ghorbani-m commented 6 months ago

@gorhom I can reproduce consistently with the following steps:

In a bottomSheetModal > bottomSheetScrollView > bottomSheetTextInput:

  • focus the textinput
  • scroll the textinput out of view
  • close the keyboard by clicking on "ready"

I faced same issue, with bottomSheetFlatList and inevitably replaced it with FlatList to avoid app crashes on IOS

vibinjoby commented 6 months ago

+1 facing same issue with BottomSheetModal > BottomSheetScrollView > BottomSheetTextInput The workaround which fixed for me was to swap BottomSheetScrollView with https://www.npmjs.com/package/react-native-keyboard-aware-scroll-view and BottomSheetTextInput with regular TextInput

dzanynwa commented 4 months ago

Facing the same issue, @gorhom could you please take a look at this?

bmovement commented 4 months ago

If it helps, it only crashes for me when I swipe down to close the bottom sheet while the BottomSheetTextInput has focus.

bmovement commented 4 months ago

I ended up working around it by using a custom useKeyboardHeight hook to offset my snap points when the keyboard opens/closes instead of using BottomSheetTextInput.

alyxb commented 2 months ago

Same issue here with BottomSheetTextInput and BottomSheetScrollView. Has anyone found a work around without sacrificing any functionality?

liellevi commented 4 weeks ago

hey. also facing this issue with android. crash when close BottomSheetTextInput. there is any solution?