File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
packages/kit/src/runtime/client Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -1539,12 +1539,20 @@ export function create_client(app, target) {
15391539 // Removing the hash does a full page navigation in the browser, so make sure a hash is present
15401540 const [ nonhash , hash ] = url . href . split ( '#' ) ;
15411541 if ( hash !== undefined && nonhash === location . href . split ( '#' ) [ 0 ] ) {
1542+ // If we are trying to navigate to the same hash, we should only
1543+ // attempt to scroll to that element and avoid any history changes.
1544+ // Otherwise, this can cause Firefox to incorrectly assign a null
1545+ // history state value without any signal that we can detect.
1546+ if ( current . url . hash === url . hash ) {
1547+ event . preventDefault ( ) ;
1548+ a . scrollIntoView ( ) ;
1549+ return ;
1550+ }
1551+ update_scroll_positions ( current_history_index ) ;
15421552 // set this flag to distinguish between navigations triggered by
15431553 // clicking a hash link and those triggered by popstate
15441554 hash_navigating = true ;
15451555
1546- update_scroll_positions ( current_history_index ) ;
1547-
15481556 current . url = url ;
15491557 stores . page . set ( { ...page , url } ) ;
15501558 stores . page . notify ( ) ;
You can’t perform that action at this time.
0 commit comments