Repository navigation
fix(solid): keep Frame, modals and Android back in sync with router history (0.2.2) - #6
Merged
Merged
Conversation
…istory - Router changes that arrive while the Frame sync is locked are applied once it unlocks instead of being dropped. Re-tapping a modal link after closing it, or navigating during a router back, did nothing. - Closing a modal natively (Close link, Android back, iOS sheet swipe) pops its history entry when it was pushed over the same page, so the next hardware Back is not spent on a duplicate `/posts` entry. Deep-linked modals still just drop `@modal` in place. - A deep-linked modal opened twice on Android. Modal opens now wait for their page to be visible, and stale or cancelled opens never present. - While a modal is presented, Android back is left to the dialog, matching the iOS sheet dismissal. - `replace` drops the outgoing page from the Frame backstack (core decides backstack membership from the outgoing entry), and router back goes to the backstack page for the target path, across several entries if needed. - The router is only reconciled to the visible page after native pops it did not start, so a tap made during a push animation is no longer undone.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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 flaky navigation in the Solid flavor after the Solid 2 / Vite upgrade: links that only navigate on the first tap, and Android hardware Back being swallowed after closing a
?@modal=route. Also bumps to 0.2.2.Root causes (each reproduced on an Android API 36 emulator)
syncFrameToRouterStatereturned early while the navigation guard was held, and nothing re-ran it. After a modal closed,prevModalPathstayed stale, so tapping the sameAuthorlink again did nothing (curIndex: 3 prevIndex: 3, no modal). Navigations landing during a router back were lost the same way./posts?@modal=…. Closing it replaced that entry with/posts, leaving two/postsentries. The first hardware Back moved between them and nothing changed on screen. (Back feat: tanstack router updates #1 does reach the router's back handler; the history index goes 2 → 1 on the same path.)/posts?@modal=/users/3from/was opened by both the deferred post-navigate timer and the next sync. Android'sattemptShowModalnever rechecked the request id, so two dialogs stacked, and Back left one orphaned over Home.replacekept the wrong page. It passedbackstackVisible: falsefor the new page. Core decides backstack membership from the outgoing entry, so the replaced page stayed reachable by Back.reconcileRouterToVisiblePathran on everynavigatedTo, so a page that finished animating in after the router had moved on forced the router back to it.Changes
scheduleSync) and re-run when the guard releases, so no router change is dropped. Mismatch retries no longer rely on a signal write that Solid dedupes, and they're bounded.modalLifecycleLockis gone).@modalin place.replaceflags the outgoing navigation entry. Router back usesframe.goBack(entry)for the nearest backstack page with the target path, and replaces in place when there is none.The React provider has no modal machinery and isn't changed here. It does have the same dropped-sync and
replacepatterns, which can be a follow-up.Testing
test/router-provider-modal.test.ts(8 cases) against a shared fake Frame/Page (test/support/fake-frame.ts) that models core's outgoing-entry backstack rule and async dialog dismissal. 6 of the 8 fail onmain.tsc --noEmitclean.adbtaps): original repro (close modal → one Back reaches/), re-tap the same modal, deep-linked modal opens once and Back keeps/posts, Back with a modal open, detail push/pop, rapid tap/Back stress.Frame.goBack()as the native pop): the same flows plus sheet dismissal. Router, Frame backstack and presented modal stayed consistent at every step.