Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js 15 <Link> scroll to top does not work if loading.tsx is present #74485

Open
LoV432 opened this issue Jan 3, 2025 · 1 comment
Open
Labels
Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@LoV432
Copy link

LoV432 commented Jan 3, 2025

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/youthful-davinci-xs9gmf

To Reproduce

  1. Run the server in production mode (npm run build && npm run start).
  2. Navigate to the "/withloading" page.
  3. Scroll to the bottom and click the "Next" button.
  4. The page does not scroll to the top.

Current vs. Expected behavior

The page should scroll to the top when pressing the "Next" and "Previous" buttons on the "withloading" page, but it does not.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 8198
  Available CPU cores: 4
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.1.1-canary.24 // Latest available version is detected (15.1.1-canary.24).
  eslint-config-next: N/A
  react: 19.0.0-beta-04b058868c-20240508
  react-dom: 19.0.0-beta-04b058868c-20240508
  typescript: 5.1.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Navigation

Which stage(s) are affected? (Select all that apply)

next start (local)

Additional context

This bug only occurs with next start and not with next dev. It is also present only in Next.js 15 and works fine in Next.js 14. As far as I know, it doesn't matter what is returned by loading.tsx, as returning anything at all will result in this bug.

@LoV432 LoV432 added the bug Issue was opened via the bug report template. label Jan 3, 2025
@github-actions github-actions bot added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label Jan 3, 2025
@LoV432 LoV432 changed the title Next.js 15 <Link> scroll to top does not work if Loading.tsx is present Next.js 15 <Link> scroll to top does not work if loading.tsx is present Jan 3, 2025
@alexmarqs
Copy link

Having the same issue with Nextjs 15. Just replaced my loading files by Suspense's inside my layouts/pages as workaround.

@samcx samcx removed the bug Issue was opened via the bug report template. label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

No branches or pull requests

3 participants