Repository navigation
fix(pages): commit the destination URL when navigating with preserveState - #531
Merged
Merged
Conversation
…tate preserveState now only controls component state preservation. Normal visits always write history (push, or replace with replace: true); back/forward traversal still skips history writes and router.refresh() replaces the current entry instead of adding one. Fixes voidzero-dev#506
- router.refresh() goes through one shared helper used by the core and React routers. React's copy still pushed a new history entry. - refresh() keeps the URL hash; it now replaces the entry, which dropped it. An internal _refresh flag stops it from being taken as a hash-only visit, so the page is still fetched. - Same-page hash visits write history with preserveState too, like other visits. - A replaced history entry keeps its scroll key, so repeated refreshes no longer add a saved position each time. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Brooooooklyn
approved these changes
Oct 22, 2026
Contributor
Author
|
Thank you!!! |
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.
Fixes #506
Summary
router.visit(url, { preserveState: true })updated the page but skipped the history write, so the address bar kept the old URL.makeCommit()inpackages/void/src/pages/navigation-engine.tsgated the history write on!options.preserveState; it now gates on!options._popstate._popstate) skips it.preserveStatenow only affects component state;replacestill choosesreplaceStatevspushState.router.refresh()defaults toreplace: true, so it updates the current entry instead of pushing a new one.#507 is a separate bug and is not addressed here.
Tests
Added 4 cases to
packages/void/test/unit/pages-client.test.ts:preserveState+ push writes the destination URL withpushStatepreserveState+replacewrites it withreplaceStaterefresh()does not push a new history entryThe push/replace cases fail on
mainand pass with this change.vp test run test/unit/pages-client.test.tspasses (53/53); typecheck, fmt and lint pass.Follow-up changes (085e16b)
router.refresh()now goes through one sharedrefreshPage()helper, used by both the core router and React's own router. React's copy was missed and would have pushed a new entry.refresh()keeps the URL hash. Replacing the entry withpathname + searchdropped#hash. An internal_refreshflag makes sure the page is still fetched and not treated as a hash-only visit.visit('#x', { preserveState: true })) now write history too, by the same rule. The fix: Hash navigation should not make requests + should not reset fonts/css. #130 test that asserted otherwise is updated.refresh()calls (e.g. polling) don't add one saved position per call to sessionStorage.router.refresh()example notes it keeps the same history entry.