-
Notifications
You must be signed in to change notification settings - Fork 58
Description
I found a small bug in scroll position restoration when using found router (which uses farce and scroll-behavior under the hood).
Scroll position is saved in web browser's "session storage" as:
"@@scroll|/x": [0, 123]
where /x is the URL of the page.
Notice how the key is gonna be the same for different pages that have the same URL.
How could that happen?
For example, a user opens URL /a, then scrolls down, then focuses the web browser's address bar and enters URL /b, waits for it to load, then focuses the web browser's address bar and enters URL /a.
The result is the previously-saved scroll position being restored while it shouldn't have been because it's a completely different page, just with the same URL.
This is a result of the "session storage" being shared among all of the navigation history entries, and the INIT-ial location always doesn't have an autogenerated .key which results in such a weird bug.
My proposal would be to generate a location.key for the INIT-ial location, same way it's already done for any subsequent location.