Open justenau opened 1 week ago
Here's my 2 cents on this issue: nextjs preserves the scroll position on client side navigation (https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#6-back-and-forward-navigation), so this seems to be expected behaviour (even when it renders the not found page). Could be wrong though.
Here's my 2 cents on this issue: nextjs preserves the scroll position on client side navigation (https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#6-back-and-forward-navigation), so this seems to be expected behaviour (even when it renders the not found page). Could be wrong though.
This talks about back and forward navigation. In my example back/forward scroll position is kept as expected and it is not an issue. The issue is that if f.e. my <Link>
would lead to non-existing page in the project, the not-found
page would be opened with correct scroll position (at the top). But if page A has a link to page B and page B returns the not-found
page with notFound()
call, it keeps the scroll position of the page A.
Okay, got it - I was unable to open the codesandbox example - so I guessed the issue here. Will download the repro files and test locally - even after forking the sandbox, it is not loading anything on codesandbox
@abhi12299 Make sure you're opening /foo path once you launch the project.
I did, but it crashed the app on codesandbox - on local, I am able to repro
This only happened on next dev
- a very silly reason for this bug, but managed to fix it in the PR.
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/peaceful-pike-ktxllk?workspaceId=cc8eb0ea-4ef2-4830-9ca0-1bb04d0968ad
To Reproduce
Current vs. Expected behavior
Following the steps from the previous section I expected "Not found" page to be opened scrolled to the top but it keeps the scroll position of the /foo page.
Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure, Navigation, Parallel & Intercepting Routes
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
No response