-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Next 13 , App Dir , <Link scroll={false} href={...} >click</Link> , Clicking the link still goes top of the page #50105
Comments
I just want to add to the noise around this problem. I have a very hard time considering the appDir as "stable" without this. The fact that I can't use links which update even queryParams without a scroll reset is supremely problematic. |
Same issue here. Any workaround? |
I have the same problem! I also can't have smooth scrolling. The only solution for me was to add a < div > with the necessary height and transform it to 'use client' to achieve the smooth effect. |
Similar issue, I have page which has some links at mid part of the page, when user clicks on any link, I am able to update searchParams, and I want the user to stay at the same position of window, but the page scrolls to top, I tried using scroll={false} prop of Link component, it's not working, any workaround till the issue gets fixed? |
The only workaround I've found is to completely circumvent Next's routing. In the cases where I need to maintain scroll state, I have converted those pages to fetch the data client side and then used my own custom wrapper around It's not scalable but it works for individual scenarios. |
I am having a similar issue with When I look at the interface:
It's empty! Was this forgotten? |
Looking at the docs, there is not option to disable scroll in the |
I found a workaround for myself, and that's adding a hash value to the href and an id to the element I wanted to go to: <Link href={{ pathname: "page", hash: 'head' }} replace>
Go to page
</Link>
<div id="head"></div> |
### What Support `scroll={false}` for Link component in app router. This can be used when you don't need to scroll back to top again when route url changes. For instance hash query changes, if you want to keep the scrolling as it is, you can use this option. ### How Handling the `scroll` option in navigation reducer on client side. Fixes #50105 Fixes NEXT-1377 --------- Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Landed support for |
Awesome looking forward to using it! |
Is there a way to set the opposite as default? |
You can create a custom |
I think I've confused myself here. The default behaviour I'm getting is not scrolling to the top of the page (instead to the top of the route segment). Is this expected? I want to tell it to always scroll to the top of the whole page, unless stated otherwise. |
This was a problem in older versions of 13.x. To get the proper behavior, have you run |
### What Support `scroll={false}` for Link component in app router. This can be used when you don't need to scroll back to top again when route url changes. For instance hash query changes, if you want to keep the scrolling as it is, you can use this option. ### How Handling the `scroll` option in navigation reducer on client side. Fixes #50105 Fixes NEXT-1377 --------- Co-authored-by: Jiachi Liu <inbox@huozhi.im>
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)
App directory (appDir: true), Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue or a replay of the bug
does not have a public url but this can can be reproduced on local machine
To Reproduce
Next 13 , App Dir , page link , Clicking the link still goes top of the page , scroll false prop is not respected . Even router.push(pathname,,{scroll:false}) does not work .
Describe the Bug
Next 13 , App Dir , page link , Clicking the link still goes top of the page , scroll false prop is not respected . Even router.push(pathname,,{scroll:false}) does not work .
Expected Behavior
If Link scroll false prop is set then, page should retain scroll position
Which browser are you using? (if relevant)
chromium
How are you deploying your application? (if relevant)
local machine
NEXT-1377
The text was updated successfully, but these errors were encountered: