[pull] main from freeCodeCamp:main - #276
Merged
Merged
Conversation
State IDs were assigned with a pre-increment, so the first entry got ID 1 instead of 0. That made isIntialState() never match (canGoBack() was always true) and left isLastState() off by one (canGoForward() was always true), so the mobile back/forward buttons were never disabled. isInitialPopState() also read this.initialPath, which was only ever set as an instance property, so the static read was always undefined and the guard never fired. Capture the load-time path in a static field instead.
The app restores scroll positions itself in app.views.Content, keyed by history state ID. On the mobile layout the scroll element is the document itself, so the browser's automatic restoration targets the same element and runs asynchronously around popstate, racing with (and overriding) the restore scheduled in beforeRoute. Little is given up by opting out: on full page reloads, where the app has no cached positions, the content is still being fetched when the browser would restore, so the offset clamps to 0 anyway.
A single history entry can be dispatched more than once. On the second dispatch the route context is already the one being navigated to, so cacheScrollPosition() no longer bailed out and stored the on-screen scroll position -- the position of the page being entered -- over the position saved for that state when it was left. Going back from an in-page anchor was the visible symptom: the cached position of the anchored view replaced the position the user had scrolled to, so the restore became a no-op and the content never moved. Fixes #2445.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )