- Notifications
You must be signed in to change notification settings - Fork29.5k
Description
Link to the code that reproduces this issue
https://github.com/GlebKodrik/nextjs-bug
To Reproduce
- Clone the repo and install dependencies.
- Run the app in development mode: npm run dev.
- Scroll to the bottom of the page — you will see two buttons: Intensive and Check.
- Click either button → navigation happens via:
router.push(`?${params.toString()}`, { scroll: false })
- In development mode, the page does not scroll to top.
- Build and start the app in production:
next buildnext start
- Scroll to the bottom and click either button again → the page jumps to top unexpectedly.
- Removing loading.tsx prevents the scroll jump.
- Adding loading.tsx triggers the scroll jump again.
Current vs. Expected behavior
Current behavior:
When calling
router.push(`?${params.toString()}`, { scroll: false })
the page still scrolls to the top, but only in the production build and only when a loading.tsx file exists.
Expected behavior:
The page should not scroll to the top when { scroll: false } is passed, regardless of environment or presence of loading.tsx.
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.6.0Binaries: Node: 20.17.0 npm: 10.8.2 Yarn: 1.22.22 pnpm: 9.10.0Relevant Packages:"next":"^15.5.2","react":"19.1.0","react-dom":"19.1.0"Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Loading UI and Streaming
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
Additional context
- The issue seems to be tightly connected with the loading.tsx file. Without it, everything works fine.
- Might be related to how Suspense boundaries or loading.tsx trigger re-render and reset scroll state.
- Happens both locally and in production build environment.