Ensures App Router Link respects scroll-behavior: smooth when only hash is changed. (#54243)
Fixes https://github.com/vercel/next.js/issues/54240 The Link component in App Router is not respecting `scroll-behavior: smooth` when only the hash changes. It appears to be caused by `focusAndScrollRef.onlyHashChange = false` being set before `handleSmoothScroll` is called, causing `htmlElement.style.scrollBehavior` to be overridden to `auto` before `scrollIntoView` is called. Moving `focusAndScrollRef.onlyHashChange = false` to after `handleSmoothScroll` invocation resolves the issue.
Showing
Please
register
or
sign in
to comment