vuejs / vuejs/docs

Scroll position is not preserved when using back and forward buttons

Open
#2,381 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Vue
Stars
3.2k
Forks
5k
Avg merge
14d 17h
Merged PRs (30d)
1

Description

I expect to land on the same scroll position as I was before on a page A, when I use a back button on page B.

I end up on the top of the page A or even at a different position, instead of on the scroll position I was before.

Reproduction

  1. visit https://vuejs.org/guide/introduction.html
  2. scroll to the bottom of the page, I can now see a heading "Pick Your Learning Path"
  3. click on "Quick Start" in the left navigation menu, I am now on page https://vuejs.org/guide/quick-start.html
  4. scroll to the bottom of the page, I can now see a heading "Next Steps"
  5. hit Back button in the browser
  6. I can see the heading "Pick Your Learning Path" on page "Introduction"
  7. hit Forward button in the browser
  8. I am on page "Quick Start". I can no longer see the heading "Next Steps". I can see "Using Vue from CDN" at the top of my viewport.
  9. quickly hit back, forward, back, forward in the browser
  10. I am on page "Quick Start". I can no longer see any of the headings mentioned above, because I am on the top of the page suddenly.

Expected behavior

Ideally the scroll position would be preserved at the exact same position, as it is done on plain HTML by browsers.

The issue is not present when I disable JavaScript in DevTools.

Environment

Browser: Firefox 112
OS: Pop_OS (Ubuntu) 22.04

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the back/forward navigation sequence on the Vue documentation pages in Firefox with JavaScript enabled, then compare it with JavaScript disabled. Trace the documentation site's client-side navigation and scroll restoration behavior; done means returning to Introduction and Quick Start restores the prior scroll positions reliably during repeated back and forward navigation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.