Repository navigation
fix(history): stamp history depth from the current entry, not history.length - #707
Merged
Merged
Conversation
…length Browsers cap session history (50 entries in Chromium and Firefox). Once the cap is reached, pushState drops the oldest entry and history.length stays the same, so `history.length - 1` gave every new entry the depth of the one below it. Back then computed a zero delta (useBeforeLeave was skipped) and scroll restoration shared one slot between entries. browserHistory() and hashHistory() now stamp a pushed entry with the current depth + 1. Replace keeps the current depth as before. Fixes #694
saveCurrentDepth() stamped an entry the router didn't push (e.g. a #anchor jump) from history.length, which stops growing at the browser's cap. It now counts up from the last known depth, falling back to history.length only when none is known. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNQHxQ9311k7tQMEKs
🦋 Changeset detectedLatest commit: ac8c289 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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 #694. This replaces #695 and keeps @sarankumar1325's commit from it. That PR's branch is on a fork this repo's automation can't push to.
From #695
browserHistory().setandhashHistory().setnow stamp a pushed entry withdepth + 1instead ofhistory.length - 1. Browsers cap session history at 50 entries in Chromium and Firefox. Once the cap is reached,pushStatedrops the oldest entry andhistory.lengthstops growing. Every new entry then got the same_depthas the one below it, so on Back:deltawas 0, souseBeforeLeavenever ran;Added here
The issue suggested a second fix that #695 left out.
saveCurrentDepth()still stamped an entry the router didn't push, such as a#anchorjump, fromhistory.length. It now usesdepth + 1and falls back tohistory.length - 1only when no depth is known yet, as on first load. A new test pushes an unrouted entry at the cap and checks that it gets depth 50, not 49.This PR also merges
nextin, to pick up the rc.19 test updates from #703.Tests
pnpm testpasses (727 client, 102 server), as dopnpm test:typesand prettier.Generated by Claude Code