Skip to content

fix(status-page): remember scroll position when navigating home#259

Merged
rogeriopvl merged 1 commit into
masterfrom
fix/status-page-remember-scroll-position-when-clicking-home
Feb 1, 2026
Merged

fix(status-page): remember scroll position when navigating home#259
rogeriopvl merged 1 commit into
masterfrom
fix/status-page-remember-scroll-position-when-clicking-home

Conversation

@rogeriopvl

Copy link
Copy Markdown
Member

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 website

2 - Implement a scroll position restore feature using the window.scrollTo API and save the position when the origin link is clicked

Since 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 scrollTo call can happen before the page rendering. The way to fix this would be to place the scrollTo call in a setTimeout so 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 the setTimout and measure the results in production first.

Closes #258

@rogeriopvl rogeriopvl merged commit ed6e8d9 into master Feb 1, 2026
@rogeriopvl rogeriopvl deleted the fix/status-page-remember-scroll-position-when-clicking-home branch February 1, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep scroll position when navigating back

1 participant