Comments (17)
Hi @hqw567 and @steve-marmalade -- since catch-all routes ([...route]
) match everything except the index route (ie, /foo/bar
, /foo/bar/baz
, but not /foo
), and you're linking back to the root page, you'd ideally use an optional catch-all route here ([[...route]]
). This would include the index route. However, parallel routes don't yet support optional catch-all segments (but it's being tracked here).
In the meantime, you can work around this by having a @modal/page.tsx
component that returns null. I tested that with your provided reproduction and it appears to have worked as you expect.
from next.js.
they managed to break the router again. insane
from next.js.
Hi - as mentioned by @xvvvyz, the catch-all route is the correct way to handle this, and the docs link provided above explains why it behaves this way.
Going to close this out but don't hesitate to ask any follow-up questions if you have any :)
Hi @ztanner,
I tried using the catch-all route you mentioned, but it didn't work at all.
from next.js.
@ztanner , thanks for the quick response and the additional context! unfortunately, this didn't immediately help me, since in my application I am routing to a non-index route and still seeing the modal stay open (which it sounds like should be covered by the regular [...catchAll]
route).
I will try to modify the nextgram repo to see if I can easily reproduce.
from next.js.
Looks like you don't have a catch-all route in your @modal
slot. Read:
https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#closing-the-modal
from next.js.
@ztanner , thanks for the quick response and the additional context! unfortunately, this didn't immediately help me, since in my application I am routing to a non-index route and still seeing the modal stay open (which it sounds like should be covered by the regular
[...catchAll]
route).I will try to modify the nextgram repo to see if I can easily reproduce.
I'm having a similar problem. The slot route is not being unmounted after I navigate to a different non-index route. I've tried, default pages, null pages and catch all routes. No luck here.
from next.js.
Hi - as mentioned by @xvvvyz, the catch-all route is the correct way to handle this, and the docs link provided above explains why it behaves this way.
Going to close this out but don't hesitate to ask any follow-up questions if you have any :)
from next.js.
I am having the same issue - a modal (built using parallel + intercepted route) in my application is not closing on client-side navigation, even after adding the [...catchAll]
route. Thanks for creating the repro @hqw567 .
One observation is that I have a seen a difference between development
and production
builds. When I downgrade @hqw567 's repro to 14.1.0
and do next build && next start
, the navigation works as expected. But development mode doesn't work in 14.1.0
, and in the latest canary the navigation issue is present in both development and production builds.
from next.js.
@ztanner - I believe I have been able to create a minimal reproduction for the issue that I'm seeing where the parallel + intercepted route does not close as expected.
https://modal-catchall-repro.vercel.app/for-you
- If you click on "Open Modal", a very stripped down "modal" will appear
- If you click on "Profile Link", you will navigate to another page, but the "modal" will still be showing
- To demonstrate it's not a truly boneheaded configuration error on my part, I also have a link to another page, which does trigger the catch-all route and close the modal.
I am not sure why the modal closes is in the second case but not the first. Any help would be greatly appreciated 🙏
https://github.com/marmalade-labs/modal-catchall-repro
modal.mp4
from next.js.
Hi @ztanner - should I create a new issue with the reproduction I shared above?
from next.js.
Hi @steve-marmalade -- a new issue would be helpful, thank you! It appears to function correctly with Turbopack (--turbo
) so likely a bundling edge case that we need to fix for your particular setup.
from next.js.
@ztanner - I just created the issue here: #62948
Regarding Turbopack, am I correct that this could be a workaround in development but that it won't help the issue when deployed to Vercel (since production builds are not yet supported with turbopack)?
from next.js.
That's correct, yes -- production builds are not yet supported. Thank you for creating the issue!
from next.js.
@lhrinaldi - would you mind giving #62948 a 👍 if you think it's similar to the issue you are facing?
from next.js.
ожидали.
Hi @hqw567 and @steve-marmalade -- since catch-all routes (
[...route]
) match everything except the index route (ie,/foo/bar
,/foo/bar/baz
, but not /foo
), and you're linking back to the root page, you'd ideally use an optional catch-all route here ([[...route]]
). This would include the index route. However, parallel routes don't yet support optional catch-all segments (but it's being tracked here).In the meantime, you can work around this by having a
@modal/page.tsx
component that returns null. I tested that with your provided reproduction and it appears to have worked as you expect.
I understand correctly that using Link:
There is no way we can close a window like "menu" in the header and it will always send us to a specific page. Is that the only way I understood router.back() to help?
from next.js.
Recently I had the same problem and it was fixed using the[...catchAll]
file directory. But I wonder if the default file is not enough to solve this? I tried with default.tsx
but it dosent work. In my personal opinion, it doesn't look good to have a catchAll directory just for a modal to work on.
from next.js.
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.
from next.js.
Related Issues (20)
- Docs: Next 15 RC docs still have outdated information about caching HOT 1
- Rewrites in middleware override next.config rewrites HOT 3
- Icon component with dynamic svg imports vs bundle size
- Webpack Errors from Middleware Imports HOT 2
- NextJs Page reloads infinitely after new deployment with output: 'export' and nginx on Aws ECS. HOT 1
- Error while running next.js 14.2.4 in stackblitz environment HOT 1
- Importing `got` fails to compile with Turbopack
- `fetch` does not work when using manual suspense HOT 4
- [Next 15] Preloading multiple modules prevents the `dev` server from running
- TypeScript Templates: Confusion around ReadOnly
- Variables defined in `.env` files that do not begin with `NEXT_PUBLIC_` are not available in Middleware deployed to Vercel HOT 2
- Does the devcontainer fail for everyone or just me when attempting to build nextjs from source? HOT 1
- Does the devcontainer fail for everyone or just me when attempting to build nextjs from source?
- Next.js Web Server should serve webpack assets like WebPack Dev Server
- Could not locate an example named "with-stripe-typescript"
- pnpm build does not detect @types/react nor @types/node even tho they're defined (vercel deploy) HOT 1
- pnpm build does not detect @types/react nor @types/node even tho they're defined (vercel deploy)
- Your Team encountered an unknown problem. Please reach out to our support team for details. Learn More HOT 1
- server action transfrom incorrectly HOT 1
- Next/font does not work with Turbopack in a containerized development environment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next.js.