fix(modal): restore React mount state reset in unmount() after #2632#2664
Merged
gorhom merged 1 commit intoApr 30, 2026
Merged
Conversation
unmount() must call setState(INITIAL_STATE) when the portal was mounted. v5.2.11 checked statusRef after resetVariables(), which always left status INITIAL, so the condition never matched and mount stayed true—later present() could snap the sheet open again. Made-with: Cursor
|
I can confirm 5.2.11 made my entire app unusable, this needs to be fixed asap |
Owner
|
thanks @huextrat for submitting this PR, tested it and going to publish a new release shortly |
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.
Summary
Fixes a regression introduced in v5.2.11 with #2632 (modal status refactor): after dismissing a
BottomSheetModal, React state could keepmount: true, so a laterpresent()(e.g. fromuseFocusEffectwhen navigating) would hit the fast path and callsnapToIndex(index)—closed sheets appeared to reopen.Root cause
In v5.2.10,
unmount()saved whether the portal was mounted beforeresetVariables():In v5.2.11, the equivalent branch checked
statusRefafterresetVariables(), which always setsstatusReftoINITIAL. The guard therefore never matched andsetState(INITIAL_STATE)was skipped.The condition also only considered
PRESENTEDandANIMATING, while a completed dismiss ends asDISMISSED—so it would be wrong even if evaluated before reset.Fix
Mirror
mountintomountRefon every render (same pattern asmounted.current = mountin v5.2.10). Inunmount(), readhadReactMount = mountRef.currentbeforeresetVariables(), then callsetState(INITIAL_STATE)whenhadReactMountis true.Testing
yarn lint(biome) on./srcpasses.yarn typescriptstill reports existing errors in other files on this branch (unchanged by this PR).Checklist
Made with Cursor