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

[Bug]: Modal closing unexpectedly on IOS devices

Open boraoksuzoglu opened this issue 1 year ago • 6 comments

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

iOS

What happened?

Hello, I am experiencing an unexpected issue in my application. The problem occurs when state value changes. The modal opens normally and it automatically closes when value change. Probably it's an rerender problem, idk.

Expected Behavior: The modal should not close when the state value changes. The user should be able to keep the modal open and continue their operations.

Actual Behavior: The modal automatically closes when the value change.

Resolution: I found that switching BottomSheet to BottomSheetModal resolved the issue, and the modal behaves as expected without closing unexpectedly. You can check it at the Expo Snack link.

Versions:

  • Expo: 52.0.26
  • React Native: 0.76.6
  • @gorhom/bottom-sheet: 5.0.6
  • react-native-reanimated: ~3.16.1
  • react-native-gesture-handler: ~2.20.2

Reproduction steps

  • Basic usage of BottomSheet.

Reproduction sample

https://snack.expo.dev/@boraoksuzoglu/bottom-sheet---issue-reproduction-template?platform=ios

Relevant log output


boraoksuzoglu avatar Jan 24 '25 09:01 boraoksuzoglu

+1 We have the same problem. Unable to get any logs or anything. No explanation for it. Sometimes it disappears, sometimes it doesn't. It is not due to snapPoints to 0 or anything. There is also no way to get the status of the bottom sheet, making it impossible to catch this behavior and handle it correctly. Please fix this asap.

HugoBounoua avatar Jan 24 '25 22:01 HugoBounoua

Ugly workaround for now for those experiencing the same problem: useEffect(() => { if(bottomSheetRef?.current) setTimeout(() => bottomSheetRef?.current && bottomSheetRef?.current.snapToIndex(0), 1000); }, [bottomSheetRef?.current]);

HugoBounoua avatar Jan 24 '25 22:01 HugoBounoua

I'm having a similar issue. I load my app with an index of -1. Then I click on a marker on a map, it sets some data about that marker to the state and snaps the index to 1. the next time I click a marker the sheet goes to an index of -1. But after that initial flicker, the data in the sheet will update without it going away.

I also notice that when this happens, onClose is called twice. But I don't have any code that is calling the sheet to do anything except snap to index.

spencexyz avatar Jan 29 '25 03:01 spencexyz

thanks @boraoksuzoglu for reporting this issue, it should be fixed on the next release

gorhom avatar Feb 03 '25 18:02 gorhom

I'm still having this issue in the last release

smontlouis avatar Mar 26 '25 09:03 smontlouis

I'm having a similar issue. I load my app with an index of -1. Then I click on a marker on a map, it sets some data about that marker to the state and snaps the index to 1. the next time I click a marker the sheet goes to an index of -1. But after that initial flicker, the data in the sheet will update without it going away.

I also notice that when this happens, onClose is called twice. But I don't have any code that is calling the sheet to do anything except snap to index.

https://version-control9.github.io/said/

luigi-old727 avatar Oct 10 '25 15:10 luigi-old727