Next.js Discord

Discord Forum

Page scrolling back to top on router.replace(newUrlWithQueryParam, { scroll: false })

Unanswered
Connorcon2020 posted this in #help-forum
Open in Discord
Technical Specifications:
- Expected Behavior Version: 15.5.1-canary.3
- Unexpected Behavior Version: 15.5.1-canary.4
- Using App Router

I have used router.replace(newUrlWithQueryParam, { scroll: false }) to update query parameters to maintain page scroll, but starting in 15.5.1-canary.4 it now has started snapping to the top of the page. One thing I have noticed is this only seems to happen on a page containing a loading.tsx, other than that I haven't noticed a pattern on why it happens in some places and not others.

Is this a new bug introduced that will be fixed or is there a solution in place to ensure it doesn't scroll back to the top of the screen without directly altering the path via the window, as ideally I'd like to maintain using next router to keep a stack trace of the route.

3 Replies