diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js index 156a9c314c35..c4f78548655c 100644 --- a/packages/kit/src/runtime/client/client.js +++ b/packages/kit/src/runtime/client/client.js @@ -3015,18 +3015,10 @@ function reset_focus(url, scroll = null) { resetting_focus = true; location.replace(new URL(`#${id}`, location.href)); - // if we're using hash routing, we need to restore the original hash after - // setting the focus with `location.replace()`. Although we're calling - // `location.replace()` again, the focus won't shift to the new hash - // unless there's an element with the ID `/current-pathname#hash`, etc. - if (app.hash) { - location.replace(url); - } - - // but Firefox has a bug that sets the history state to `null` so we - // need to restore it after. - // See https://bugzilla.mozilla.org/show_bug.cgi?id=1199924 - history.replaceState(history_state, ''); + // Firefox has a bug that sets the history state to `null` so we need to + // restore it after. See https://bugzilla.mozilla.org/show_bug.cgi?id=1199924 + // This is also needed to restore the original hash if we're using hash routing + history.replaceState(history_state, '', url); // Scroll management has already happened earlier so we need to restore // the scroll position after setting the sequential focus navigation starting point