vercel / next.js

The React Framework
https://nextjs.org
MIT License
126.31k stars 26.89k forks source link

Intercepted route is triggered outside of its defined subpath and ignored if previous navigation is known by the browser router cache #59067

Open Julienng opened 11 months ago

Julienng commented 11 months ago

Link to the code that reproduces this issue

To Reproduce

To see the intercepted route trigger: From index page:

  1. Click on users link
  2. Click user 1 link → modal is shown
  3. Click index
  4. Click on shortcut user 1 → users page + modal is shown

In reverse, intercepted route not triggered when a previous navigation was done outside of /users route: From index page:

  1. Click on shortcut user 2 → user's full page is shown
  2. click on users
  3. click on user 2 → user's full page is shown

Current vs. Expected behavior

In the current behavior, Nextjs is using the client cache of a previous navigation even outside of the defined subpath for the intercepted route.

I was expecting that Nextjs will open full-page outside /users page and always intercept a route inside /users page, even when a previous navigation is known by the router on the client cache for that specific route.

Verify canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.6.0: Wed Jul  5 22:21:53 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6020
Binaries:
  Node: 20.9.0
  npm: 10.1.0
  Yarn: 1.22.19
  pnpm: N/A
Relevant Packages:
  next: 14.0.2
  eslint-config-next: 14.0.2
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: standalone

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

App Router

Additional context

No response

simonstudios commented 10 months ago

I'm also experiencing this issue. It occurs even when I build the example given in the documentation.