react-native-bottom-sheet icon indicating copy to clipboard operation
react-native-bottom-sheet copied to clipboard

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

Open motudev opened this issue 1 year ago • 15 comments

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

motudev avatar Sep 08 '23 12:09 motudev

same issue

thdeptrai avatar Sep 08 '23 15:09 thdeptrai

looking into this issue at the moment

gorhom avatar Sep 11 '23 18:09 gorhom

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

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

gorhom avatar Sep 11 '23 19:09 gorhom

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

Maybe the stacktrace will help. stacktrace.txt

motudev avatar Sep 12 '23 07:09 motudev

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

motudev avatar Oct 16 '23 11:10 motudev

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

ivoneug avatar Nov 03 '23 13:11 ivoneug

Same here

mo6zes avatar Nov 24 '23 12:11 mo6zes

@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"

mo6zes avatar Nov 24 '23 13:11 mo6zes

@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

ghorbani-m avatar Feb 07 '24 09:02 ghorbani-m

+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

vibinjoby avatar Feb 22 '24 22:02 vibinjoby

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

dzanynwa avatar Apr 09 '24 10:04 dzanynwa

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

bmovement avatar Apr 18 '24 20:04 bmovement

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.

bmovement avatar Apr 18 '24 21:04 bmovement

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

alyxb avatar Jun 18 '24 22:06 alyxb

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

liellevi avatar Jul 29 '24 08:07 liellevi