Description
Version
2.7.0
Reproduction link
https://github.com/vuejs/vue-router/tree/dev/examples/scroll-behavior
Steps to reproduce
Sorry, because this requires history navigation I can't give too great of a link. This manifests itself in the scroll-behavior example of the vue-router repo, though.
Basically, open a new tab to the scroll behavior example: http://localhost:8080/scroll-behavior/bar
Scroll just a little bit down and click on the "bar" link. It will correctly scroll to the top again. When you press back it will stay at the top, though, and not go to the previous scroll. By the way, for me this doesn't manifest in Chrome. I believe they are doing their own scrolling by default for history navigation through this: https://developers.google.com/web/updates/2015/09/history-api-scroll-restoration
Firefox should manifest the issue, though.
What is expected?
I expect it to be able to scroll properly even for initial route.
What is actually happening?
It doesn't scroll correctly.
The reason it happens is since the first request wasn't done through a pushState there is no state object stored. It needs the state object to store the scroll position.
This issue is probably known, however I think we may be able to fix it by doing a replaceState right away with a new state object, yeah?