Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Next.js `13.3.5-canary.2`
Link to the code that reproduces this issue
To Reproduce
- Click the counter to update client state.
- Scroll a little.
- Click the second button to update search params.
- The client state is preserved, but the scroll position is lost.
Describe the Bug
Context
In Next <= 13.2.4, updating search params was working as intended : client state was kept, and scroll position was kept too.
In Next 13.2.5, a regression made the client components unmount and remount when search params were updated.
@feedthejim fixed that unmounting in #49047 (it's testable on 13.3.5-canary.2
), but there is still an issue now: scroll position is lost on search params updates.
Problem: persisting state in search params is very important with the App router - that's a clean way for client components to request updated data from the RSC.
Reproduction Codesandbox
Here's a codesandbox reproducing the bug:
In video
CleanShot.2023-05-02.at.14.18.36-converted.mp4
A real-world example of the problem
Previously, the "name for the fund", kept in client state, was reset when updating the sliders. It's now better, but the scroll position reset is still awkward.
CleanShot.2023-05-02.at.14.31.38.mp4
Expected Behavior
When updating search params, the scroll position should be preserved.
Which browser are you using? (if relevant)
Latest stable Google Chrome
How are you deploying your application? (if relevant)
No response