mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-20 01:25:16 +00:00
Prevent hash link scroll to top in Safari (#4055)
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user