fix: Another fix for heading scrolling

This commit is contained in:
Tom Moor
2023-06-10 15:50:05 +03:00
parent d319bb7d9a
commit 746c27e718

View File

@@ -94,12 +94,9 @@ const NavLink = ({
React.useLayoutEffect(() => {
if (isActive && linkRef.current && scrollIntoViewIfNeeded !== false) {
// If the page has an anchor hash then this means we're linking to an
// anchor in the document generally smooth scrolling the sidebar may
// interrupt the scrolling to the anchor of the document so we jump
// directly to the anchor instead.
if (window.location.hash) {
linkRef.current.scrollIntoView();
} else {
// anchor in the document smooth scrolling the sidebar may the scrolling
// to the anchor of the document so we must avoid it.
if (!window.location.hash) {
scrollIntoView(linkRef.current, {
scrollMode: "if-needed",
behavior: "auto",