fix(adapters): recover gorhom from dropped onChange; drop dead swmansion settle guard#30
Merged
Merged
Conversation
…ion guard gorhom: under rapid open/close (switch then an immediate dismiss), gorhom can drop its onChange, leaving a re-revealed sheet stuck in 'opening'. That permanently trips the open() guard (hasOpeningInGroup), so every later open is a no-op. Report opened from the animated index as a reliable backstop (idempotent via the status guard). swmansion: onSettle is now optimistic (fires when the animation starts), so a settle at the collapsed detent only ever follows a real close. The closeRequestedRef guard is dead — drop it and handle the settle directly. example: ScannerSheet (persistent) now uses the swmansion adapter, covering the swmansion + persistent (defaultIndex < 0) path.
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.
Two open/close lifecycle race fixes in the adapters
gorhom — sheet stuck in
'opening', all opens blockedRepro: open a sheet, tap switch, then immediately dismiss (backdrop/gesture) before it finishes opening → afterwards
push/switch/replacedo nothing (app responsive, buttons dead).Cause:
switchsets the sheet below to'hidden'and starts closing it. Dismissing the new top re-reveals the below sheet ('hidden' → 'opening') and callsexpand()while its close animation is still in flight. gorhom swallows thatexpand()and never emitsonChange— the only signal that drovehandleOpened. The sheet stays'opening'forever, which permanently trips thehasOpeningInGroupguard inopen(), so every subsequent open is a no-op.Fix: report opened from the animated index (a reliable signal gorhom keeps updating even when it drops the JS callback) via a
useAnimatedReaction— firehandleOpenedwhen the index crosses into an open snap point. Idempotent (the coordinator'smarkOpenonly acts while'opening'). The existingonChange → handleOpenedpath is untouched; this is an additive backstop. UsesscheduleOnRN(not the deprecatedrunOnJS).swmansion — drop the now-dead settle guard
onSettleis now optimistic (fires when the animation starts), so a settle at the collapsed detent only ever follows a real close — the oldcloseRequestedRef/hasOpenedRefguard against a spurious pre-opensettle(0)no longer fires. Verified empirically (including thedefaultIndex < 0/ persistent path): open emitssettle(openIndex), close emitssettle(0), and a mount-timesettle(0)(if any) is absorbed by the coordinator'sstatus !== 'hidden'check. The guard is removed; the settle is handled directly.example
ScannerSheet(a persistent sheet) now uses the swmansion adapter, adding coverage for the swmansion + persistent (defaultIndex < 0) combination that previously had none.No changes to the shared store / coordinator.