From 95f8b3a6180f5e67dec3e36db75ffcb9b1f1e9dc Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Tue, 23 May 2023 20:44:37 +0000 Subject: [PATCH] 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. --- web/src/hashchange.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/src/hashchange.js b/web/src/hashchange.js index 2a81dbaefd..88c1a344c4 100644 --- a/web/src/hashchange.js +++ b/web/src/hashchange.js @@ -420,6 +420,10 @@ function hashchanged(from_reload, e) { } 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) => { hashchanged(false, e.originalEvent); });