-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Parallel routes do not clear slot with [...catchAll] #48719
Comments
like I mentioned here#48090, it seems dynamic route or catch-all route still not compatible with parallel route, I think it may have some work to do. |
Did a little research on the code - the essence of the problem is that all It seems that appPaths should contain any of the next.js/packages/next/src/server/dev/next-dev-server.ts Lines 568 to 573 in cad6d3a
Perhaps there is a similar code in other packages for generating pages (I could not find it correctly).. For example {
"/": ["/page", "/@extension/page"],
"/[...catchAll]": ["/@extension/[...catchAll]/page"],
"/overview": ["/overview/page", "/@extension/overview/page"],
"/demo": ["/demo/page"]
} But they should look like this: {
"/": ["/page", "/@extension/page"],
"/[...catchAll]": ["/@extension/[...catchAll]/page"],
"/overview": ["/overview/page", "/@extension/overview/page"],
"/demo": ["/demo/page", "/@extension/[...catchAll]/page"]
} |
I just ran into this issue on |
Any updates on this? Right now feels impossible to use Parallel routes with Dynamic routes. |
Any progress? |
tired many things nothing work just route.back() ... and yeah still we need fix. |
Updated the issue to the latest canary version |
Could you see this issue? The whole app is unmounted in the case described there without any error. |
Here's a workaround:
Dummy page looks like this: export default function Page() {
return null
} |
Since I ran into the same problem, I also created a simple codesandbox. The desired result is that the subheader that is displayed following a soft navigation to |
I have created a draft PR with failed tests and further context, if anyone would like to add feedback please feel free to do so. |
thanks @stefanofa for adding a repro. I was looking into this and you're right that it should work. I'll try to fix this in the next one-two weeks. It's not super straightforward to fix unfortunately. |
Thanks @feedthejim for taking care of it. Since this is part of the topic, I have a question to ask, namely why do the slots during soft navigation behave as described in the docs? Thinking about it I can't think of any concrete use cases, although I'm most likely missing something. |
This PR fixes a bug where parallel routes would not apply appropriately on navigation when used within slots. The following scenarios: ``` /foo /bar /@slot /[...catchAll] ``` or ``` /foo /[...catchAll] /@slot /bar ``` will now function correctly when accessing /foo/bar, and Next.js will render both /bar and the catchall slots. The issue was that the tree constructed by `next-app-loader` for a given path, /foo/bar in the example, would not include the paths for the catch-all files at build time. The routing was done 1-1 when compiling files, where a path would only match one file, with parallel routes, a path could hit a defined path but also a catch all route at the same time in a different slot. The fix consists of adding another normalisation layer that will look for all catch-all in `appPaths` and iterate over the other paths and add the relevant information when needed. The tricky part was making sure that we only included the relevant paths to the loader: we don't want to overwrite a slot with a catch all if there's already a more specific subpath in that slot, i.e. if there's /foo/@slot/bar/page.js, no need to inject /foo/@slot/bar/[...catchAll]. One thing that is not supported right now is optional catch all routes, will add later. fixes #48719 fixes #49662
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. |
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP Fri Jan 27 02:56:13 UTC 2023 Binaries: Node: 19.7.0 npm: 9.5.0 Yarn: N/A pnpm: 8.8.0 Relevant Packages: next: 13.5.4-canary.1 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: N/A Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue
/~https://github.com/Yukioru/next-parallel-routes-bug
https://codesandbox.io/p/github/Yukioru/next-parallel-routes-bug/main
https://next-parallel-routes-bug.vercel.app
To Reproduce
You have to use soft navigation
Describe the Bug
Once the slot is shown, it is not cleared if the URL does not match.
A similar bug has already been described in Issue: #48124, but the solution with
[...catchAll]
route did not help. The route is not called.If you do a hard navigation, you will see that the
/demo
slot segment corresponds to the default.js route, but it does not show up.Expected Behavior
Using soft navigation (next/link) the slot should be cleared by the
[...catchAll]
route (or thedefault.js
route if possible).Which browser are you using? (if relevant)
Chrome 112.0.5615.138
How are you deploying your application? (if relevant)
Vercel, CodeSandbox
NEXT-1394
The text was updated successfully, but these errors were encountered: