fix(status-page): remember scroll position when navigating home#259
Merged
rogeriopvl merged 1 commit intoFeb 1, 2026
Merged
Conversation
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.
There were a couple of ways to address this:
1 - Using the browser's History API calling
back(), which would get us the scroll position feature "for free", but would create weird use cases such as when the user lands on a status page coming from another website (ie. google.com) clicking the link "back to home" would take the user back to that other website2 - Implement a scroll position restore feature using the
window.scrollToAPI and save the position when the origin link is clickedSince the purpose of the "Back to Home" link is to take the user to the http cats homepage and not technically back in the browser history. I ended up choosing the second approach because it suites better the purpose of the link.
This implementation is prone to a race condition on slower devices where the
scrollTocall can happen before the page rendering. The way to fix this would be to place thescrollTocall in asetTimeoutso that its queued after the page rendering. The problem is that this introduced delay can be seen and makes the interaction look less fluid, so I removed thesetTimoutand measure the results in production first.Closes #258