Replies: 7 comments 10 replies
-
I added a comment to the issue before it was converted to a discussion, to bad it got lost but I can add it again luckily. Originally I saw the issue was made for nextjs version 9.4. I've updated my links to the current version. Thanks @timneutkens for converting though! Original text: I guess this boils down to being able to pass something like router.push('#dont-go-here', undefined, { scroll: false }; I am facing a similar issue where I want to apply smooth scrolling to links (to anchor links on the same page). On links to a new page, the smooth scroll is "weird" UX. So in complement another option to add to this request would be adding a behaviour option as well, because that can be added to the router.push('#dont-go-here', undefined, { scroll: false, behaviour: 'smooth' }; |
Beta Was this translation helpful? Give feedback.
-
Hi, is this change published, if so, how can I use it? Next.js document lacks a lot of use cases. |
Beta Was this translation helpful? Give feedback.
-
Faced the same issue. If the url doesn't have hash, This behaviour is a little bit surprising. I would just align the scroll behaviour with non-hash url when In my use case, the url is always the same because I just want to re-render by fetching the new page props. |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
Up ! |
Beta Was this translation helpful? Give feedback.
-
Any news? |
Beta Was this translation helpful? Give feedback.
-
I also require the ability to use router.replace(
{
hash: 'some-hash',
},
undefined,
{ scroll: false },
); However, it appears that |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Feature request
Is your feature request related to a problem? Please describe.
I want to use url hash (e.g.
/page#something
) to show a user-shareable state in a page.However,
Router.replace
causes scrolling to the anchor element.https://github.com/vercel/next.js/blob/v9.4.4/packages/next/next-server/lib/router/router.ts#L408
To avoid this behavior and other side effects, we can call History API manually:
Although it works correctly, it is very fragile as it depends on internal implementation of Next.js.
There is a similar issue (#6862) but
shallow
option does not help in this case.Describe the solution you'd like
Add new method to Router to call
history.replaceState
above in a consistent manner.What I really want is just to replace hash, so the replacement can be limited to hash only rather than whole url.
Beta Was this translation helpful? Give feedback.
All reactions