react-native-bottom-sheet
react-native-bottom-sheet copied to clipboard
[v4] IOS: Closing Keyboard crashes if BottomSheetTextInput is inside of BottomSheetFlatlist or BottomSheetScrollView
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
- Open the app
- Scroll to the bottom of the Flatlist
- open the keyboard by selecting the textinput that is the last one you can see
- close it by pressing enter
- App crashes
Describe what you expected to happen:
- The Keyboard closes and restores the bottomsheet to its former state
Reproducible sample code
https://github.com/motudev/bottomsheet-example
same issue
looking into this issue at the moment
I tried to repo the issue, but it did not crash :\
@motudev, @thdeptrai could you retest on the latest version and let me know ?
I tried this on latest release(updated the repo i provided accordingly) it still crashes.
Maybe the stacktrace will help. stacktrace.txt
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
I'm also experiencing the same issue in release build only. @gorhom do you have any plans to fix this?
Same here
@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"
@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
+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
Facing the same issue, @gorhom could you please take a look at this?
If it helps, it only crashes for me when I swipe down to close the bottom sheet while the BottomSheetTextInput
has focus.
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
.
Same issue here with BottomSheetTextInput and BottomSheetScrollView. Has anyone found a work around without sacrificing any functionality?
hey. also facing this issue with android. crash when close BottomSheetTextInput
. there is any solution?