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

[v4] | [v2] Modal not dismissing #1775

Open
louie-pangan opened this issue Mar 27, 2024 · 5 comments
Open

[v4] | [v2] Modal not dismissing #1775

louie-pangan opened this issue Mar 27, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@louie-pangan
Copy link

louie-pangan commented Mar 27, 2024

Bug

We are using multiple modals (open at the same time) in our project.
There are instances when closing the modal either tapping outside of the modal or calling dismiss from useBottomSheetModal hook, useAnimatedReaction hook callback is invoke multiple times. This will then invoke _providedOnClose -> handleUnmountSheet of BottomSheetModalProvider.

Given that handleUnmountSheet of BottomSheetModalProvider will be invoke multiple times using the same key, sheetsQueueRef will be updated depending on the number of calls which may result on an empty array.
If possible to have a guard in handleUnmountSheet that if sheetIndex is -1, succeeding codes will not be executed.

The problem now is we only expected to remove only the top most modal in sheetsQueueRef but since unmount is called multiple times even the other modals were removed.
Even if we call dismissAll from useBottomSheetModal, the modal is still not closing.

Environment info

Library Version
@gorhom/bottom-sheet 4.4.5
react-native 0.72.10
react-native-reanimated ~3.3.0
react-native-gesture-handler ~2.12.0

Steps To Reproduce

  1. Implement a screen with two or more modal - the first modal occupying the whole screen with a cancel button to dismiss all modals and the succeeding modals half of the screen (when opened)
  2. Open the first modal
  3. Open another modal
  4. Close the last modal
  5. Repeat steps 3 and 4 multiple times
  6. Tap cancel

Expected Behavior:
The first modal should be closed

Actual Behavior:
The first modal is not closing

Reproducible sample code

@louie-pangan louie-pangan added the bug Something isn't working label Mar 27, 2024
@janodetzel
Copy link

Same issue

@gaberogan
Copy link

Same issue, it's causing users to complain about "freezing" and needing to force close the app

@entryxbad
Copy link

Is there any solution to this problem?

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@louie-pangan
Copy link
Author

Hi,
Would it be okay to have a checking if the key is not existing in sheetsQueue then just return?
So it will not unmount the incorrect sheet.
https://github.com/gorhom/react-native-bottom-sheet/blob/2b37e067aa027f408b32d50cc2636d4093bcacfc/src/components/bottomSheetModalProvider/BottomSheetModalProvider.tsx#L89C5-L89C40

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

4 participants