-
Notifications
You must be signed in to change notification settings - Fork 27.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App Router: Next/Link does not respect smooth scroll #51721
Comments
Possible related to #44295, only current workaround is by define the style inside html {
scroll-behavior: smooth !important;
} |
Having the same issue as well, got a test deployment up in case that helps: |
Note that this has a possible unwanted side effect: navigating to a different page will not set the scroll position instantly but will also scroll to top smoothly. |
To clarify this further, you're expecting As @Manduro said we saw many cases where people added |
Perhaps a new prop to override the smooth behavior on a per case basis would be ideal to get a wider range of possibility.
and same for different pages:
The last one may be weird depending if you go to the top first or not. |
I'd prefer not introducing different behavior / props, just mirroring what |
It would be great if different page hash link could also scroll smoothly, but if this would prove problematic with non-hash links scrolling to top then at least same-page hash smooth scroll as per your original suggestion would be fine. Worst case it should still be possible to achieve different page smooth scroll using normal |
We were preventing smooth scrolling to avoid jarring UX when `scroll-behavior: smooth` was set and the user navigates to another route ([PR](#40642) and [related comment](#51721 (comment))). This updates both pages & app router to restore smooth scroll functionality if the only the route hash changes. Fixes #51721 Closes NEXT-1406
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/boring-carson-rhrf23?file=%2Fapp%2Flayout.tsx%3A9%2C1
To Reproduce
Use the two different navbars to see smooth scroll difference between Next/Link and normal anchor tag.
Describe the Bug
Next/Link does not scroll smoothly
Expected Behavior
Next/Link should scroll smoothly
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-1406
The text was updated successfully, but these errors were encountered: