Browser "back" button doesn't scroll back from anchors in current page
See original GitHub issueDescribe the bug
It’s a little easier to describe this bug with the reproduction, but the gist is that when you click a link with an anchor (e.g. <a href="#foo">
), then click the browser’s back button, the page doesn’t scroll back to where you were before you clicked the anchor. Instead it just stays at the same scroll position as the target, although it does properly change the url hash.
Testing the behavior on other sites (e.g. any wikipedia page with a table of contents) confirms that the browser does normally remember your scroll position when navigating between anchor elements on the same page.
Reproduction
- Go here as an example: https://sveltesaas.com/articles/sveltekit-github-pages-guide/
- Scroll down and click the “Install SvelteKit” link in the Getting Started section. The page will properly scroll down to the correct section.
- Click your browser’s “back” button. The URL will correctly change but the page will not scroll back to where you were before, as it usually does when navigating between anchors on the same page.
Logs
No response
System Info
Firefox 96.0.2 on Mac 12.1
Severity
annoyance
Additional Information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Browser scrolling to previous position instead of anchors ...
1 Answer 1 · Remove the overflow-x: scroll from the CSS · Click on #a3, then on #a7. The content scroll to #a7...
Read more >565008 - back button doesn't take you to original anchor (even ...
The problem is that on history navigation people don't actually want to go back to the anchor they had loaded when they first...
Read more >Back button in browser with anchor links behaves incorrectly
UPDATE: This issue goes beyond the simple annoyance of having to click the BACK button 2x. In at least some cases, if I've...
Read more >Anchors on Website Page and User Clicking To Go Back
When the visitor wants to go back to the home page they will have to click the "BACK" button 3 times. I know...
Read more >Designing A Better Back Button UX - Smashing Magazine
If the “Back” link blends in with the rest of the page, users sometimes can't find a way to go back and usually...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Can I work on this issue?
I believe this is fixed now. @Glench can you upgrade to the latest version and test it out? Let me know if it’s still present or if it has resolved for you