Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Modal closing unexpectedly on IOS devices #2129

Open
boraoksuzoglu opened this issue Jan 24, 2025 · 3 comments
Open

[Bug]: Modal closing unexpectedly on IOS devices #2129

boraoksuzoglu opened this issue Jan 24, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@boraoksuzoglu
Copy link

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 boraoksuzoglu added the bug Something isn't working label Jan 24, 2025
@HugoBounoua
Copy link

+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
Copy link

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

@spencexyz
Copy link

spencexyz commented Jan 29, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants