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

Nested parallel routes slot rendered after navigating back #66502

Closed
jer-k opened this issue Jun 3, 2024 · 3 comments
Closed

Nested parallel routes slot rendered after navigating back #66502

jer-k opened this issue Jun 3, 2024 · 3 comments
Labels
bug Issue was opened via the bug report template. locked Parallel & Intercepting Routes Related to Parallel and/or Intercepting routes.

Comments

@jer-k
Copy link

jer-k commented Jun 3, 2024

Link to the code that reproduces this issue

https://github.com/jer-k/graphql-rsc-dashboard

To Reproduce

Same issue as #60541 but that is closed and can't be commented on anymore. Tagging @ztanner as I hope this reproduction helps #60541 (comment)

I came across the above issue as I was searching around to try to understand why the slot isn't falling back to the default on subsequent navigation.

In my repository above

  • Start on the home page (/)
    • You will see in the logs rendering in default { params: {}, searchParams: {} } from default.tsx#4
  • Click the RSC (No Delay) button in the header to navigate to /books
    • You will see in the logs rendering in @breadcrumbs / BreadcrumbSlot [ 'books' ] from page.tsx#11
  • Click Home in the header
    • No log from either the default.tsx or page.tsx shows up. The breadcrumbs still show Home | books instead of just Home.

Current vs. Expected behavior

  • Current: Navigation to a page that does not match a path in the slot does not revert back to the default
  • Expected: Navigation to a page that does not match path in the slot reverts back to the default

Provide environment information

npx --no-install next info

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64
  Available memory (MB): 16384
  Available CPU cores: 12
Binaries:
  Node: 20.10.0
  npm: 10.2.3
  Yarn: 1.22.19
  pnpm: 9.0.6
Relevant Packages:
  next: 15.0.0-rc.0 // Latest available version is detected (15.0.0-rc.0).
  eslint-config-next: 14.2.3
  react: 19.0.0-rc-6f23540c7d-20240528
  react-dom: 19.0.0-rc-6f23540c7d-20240528
  typescript: 5.4.5
Next.js Config:
  output: N/A


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

Parallel & Intercepting Routes

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

next dev (local)

### Additional context

_No response_
@jer-k jer-k added the bug Issue was opened via the bug report template. label Jun 3, 2024
@github-actions github-actions bot added the Parallel & Intercepting Routes Related to Parallel and/or Intercepting routes. label Jun 3, 2024
@ztanner
Copy link
Member

ztanner commented Jun 4, 2024

Hi @jer-k -- this is expected behavior with catch-all routes.

A catch-all route will match all routes except for the "index" route that it's defined in. Meaning /foo, /bar, /foo/bar, ...etc, but not /.

With parallel routes, during a soft navigation (ie when clicking a Link) the router will attempt to match the page to a corresponding parallel route. If one doesn't exist, it'll keep whatever was previously in that slot, until you refresh the page. You can learn about that behavior here.

For your use-case, since you want the index route to render the same component as your catch-all component, you could add a @breadcrumbs/page.tsx that simply does:

export { default } from "./default";

(Or it could be the catch-all component if you prefer -- either one).

We have a task to support optional catch-all routes (ie [[...catchAll]]) which also matches the index. That issue is being tracked here: #61206

@ztanner ztanner closed this as not planned Won't fix, can't repro, duplicate, stale Jun 4, 2024
@jer-k
Copy link
Author

jer-k commented Jun 4, 2024

Awesome, thank you for the info! Works perfectly using @breadcrumbs/page.tsx

Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked Parallel & Intercepting Routes Related to Parallel and/or Intercepting routes.
Projects
None yet
Development

No branches or pull requests

2 participants