question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Browser "back" button doesn't scroll back from anchors in current page

See original GitHub issue

Describe 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

  1. Go here as an example: https://sveltesaas.com/articles/sveltekit-github-pages-guide/
  2. Scroll down and click the “Install SvelteKit” link in the Getting Started section. The page will properly scroll down to the correct section.
  3. 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:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vicky1999commented, Jan 31, 2022

Can I work on this issue?

0reactions
benmccanncommented, Feb 21, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found