Prevent hash link scroll to top in Safari (#4055)

This commit is contained in:
Claire Chabas
2026-02-26 12:27:04 +00:00
committed by GitHub
parent b9b444c24e
commit f7c4538b16
@@ -27,6 +27,13 @@ export function useScrollPage() {
return;
}
// On initial load `previousHash` can be undefined,
// but if the URL contains a fragment (hash),
// we don't override native anchor scrolling
if (!previousHash && window.location.hash) {
return;
}
window.scrollTo(0, 0);
}, [hash, previousHash]);
}