Next.js Discord

Discord Forum

Question about parallel routes and intercepting route

Unanswered
Silver carp posted this in #help-forum
Open in Discord
Silver carpOP
In the doc: https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#closing-the-modal

The good to know part state:

Good to know:

We use a catch-all route in our @auth slot to close the modal because of the behavior described in Active state and navigation. Since client-side navigations to a route that no longer match the slot will remain visible, we need to match the slot to a route that returns null to close the modal.


I don't get it. Even if I don't provide catch-all route in my code the modal still disapper with <Link href='/route-that-does-not-match-route'>Leave</Link> or even <Link href='/route-match-parent-but-does-not-match-the-slots'>Leave</Link>

What does client-side navigations to a route that no longer match the slot will remain visible mean?

I do observe that if I navigate to the same url that open the modal, the modal won't close though.
e.g. /posts/1 open a modal with intercepting route /posts/1/comments/1, if <Link href='/posts/1'/> won't close the modal. router.back() works

And a second question is, I want to fix the above question that modal won't close if link to the same page.

However, adding a catchAll route described in document doesn't work either.

0 Replies