hashchange: Disable scroll position restoration.

This avoids a bug where during a browser initiated hashchange
(via back/forward/manually typed URL) browser sets the scroll
position of the current hash based on its memory of the scroll
position of the new hash.
This commit is contained in:
Aman Agrawal 2023-05-23 20:44:37 +00:00 committed by Tim Abbott
parent 77f2562cbb
commit 95f8b3a618
1 changed files with 4 additions and 0 deletions

View File

@ -420,6 +420,10 @@ function hashchanged(from_reload, e) {
} }
export function initialize() { export function initialize() {
// We don't want browser to restore the scroll
// position of the new hash in the current hash.
window.history.scrollRestoration = "manual";
$(window).on("hashchange", (e) => { $(window).on("hashchange", (e) => {
hashchanged(false, e.originalEvent); hashchanged(false, e.originalEvent);
}); });