Fix scroll position not being preserved when pages load slowly#7143
Merged
Chocobozzz merged 2 commits intoJul 9, 2025
Conversation
Owner
|
Nice! Thank you! |
Contributor
Author
|
BTW, this PR was made during a live stream—you can watch see the final reproduction and demonstration at 2:41:24 (: |
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.
Description
Before this change, ScrollService attempted to scroll down immediately after navigating, before before the page had fully loaded.
I considered making the Table component (and other data-loading componets) responsible for telling the ScrollService that data has been loaded—or to use Angular's Route.resolve property, but realized that using ResizeObserver to get the page size is a lot more reliable (and a small code change overall, so less painful 😁).
I'm pretty sure there is some way to use RxJS observables for the
unhandledScrollEventvariable I added, but I couldn't figure out a good way to do so. (PerhapscombineLatestAllwith something to mark an event as "handled", but that "something" has been a bit elusive.) Would appreciate any pointers in that regard.Also, with the unhandled event approach, there is a chance that if only part of a page loads (or perhaps, if the page loads with a smaller size than the one it had when it was stored in history), the user might start interacting with the page, and trigger the unhandled event much later, in case something resizes the page to be tall enough.
Related issues
Fixes #7097.
To reproduce the issue, I would:
Has this been tested?