fix(modal): make dismiss idempotent when modal is not presented#2711
Open
janicduplessis wants to merge 1 commit into
Open
fix(modal): make dismiss idempotent when modal is not presented#2711janicduplessis wants to merge 1 commit into
janicduplessis wants to merge 1 commit into
Conversation
Calling dismiss() while the modal status is INITIAL (never presented, or already fully dismissed and reset) fell through the early-exit and left statusRef stuck at DISMISSING, after which every present() silently no-oped in handlePortalRender. Treat INITIAL as already-closed so dismiss() is safe to call from declarative wrappers that mirror an 'open' prop. Fixes gorhom#2669
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Calling
dismiss()on a modal whose status isINITIAL— never presented, or already self-dismissed and reset — permanently breaks it: every subsequentpresent()silently no-ops.handleDismissfalls through the early-exit and setsstatusReftoDISMISSING, nothing ever resets it (noBottomSheetis mounted to fireonClose), andhandlePortalRenderbails onDISMISSINGforever after.This breaks the common declarative wrapper pattern:
A backdrop/swipe close resets the status to
INITIAL, so the wrapper's nextdismiss()hits exactly this case.This PR treats
INITIALas already-closed inhandleDismiss, mirroringCLOSED/MINIMIZED, sodismiss()is idempotent. Full analysis and a Snack repro are in #2669.Verified in a real app on iOS after upgrading to 5.2.14: with this change, present → user close →
dismiss()→ present cycles work repeatedly.Fixes #2669
Before / after
Minimal repro (scripted):
dismiss()on a never-presented modal, thenpresent()twice.Before —
present()never works after the initialdismiss():upstream-before2.mp4
After —
dismiss()is a safe no-op andpresent()opens the sheet:upstream-after2.mp4