Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

The example from the documentation doesn't work. Link + [...catchAll] does not close modal window #65099

Closed
MrOxMasTer opened this issue Apr 26, 2024 · 6 comments
Labels
bug Issue was opened via the bug report template. Parallel & Intercepting Routes Related to Parallel and/or Intercepting routes.

Comments

@MrOxMasTer
Copy link

Link to the code that reproduces this issue

https://github.com/hqw567/nextgram

To Reproduce

  1. Set up an Intercepting Route in a Next.js application.
  2. Navigate to the page that triggers the Intercepting Route.
  3. From the Intercepting Route, use router.push('/') or a <Link href={'/'}> element to navigate back to the home page.
  4. Notice that the Intercepting Route does not close or unmount as expected.

Current vs. Expected behavior

Current Behavior:
When navigating away from an Intercepting Route using router.push('/') or <Link href={'/'}>, the Intercepting Route's component does not unmount or close, leaving the Intercepting Route's state or UI still active or visible in the background.

Expected Behavior:
Upon navigating away from an Intercepting Route using either router.push('/') or a <Link href={'/'}>, the Intercepting Route's component should unmount and close properly, similar to how it behaves when using router.back(). This ensures a consistent and predictable navigation experience within Next.js applications.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 16320
  Available CPU cores: 6
Binaries:
  Node: 20.12.2
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.3 // Latest available version is detected (14.2.3).
  eslint-config-next: 14.1.3
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.5
Next.js Config:
  output: standalone

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

#62430

https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#closing-the-modal

image

It's exactly the same situation. The modal window does not close.
image
image

@MrOxMasTer MrOxMasTer added the bug Issue was opened via the bug report template. label Apr 26, 2024
@github-actions github-actions bot added the Parallel & Intercepting Routes Related to Parallel and/or Intercepting routes. label Apr 26, 2024
@ztanner
Copy link
Member

ztanner commented Apr 26, 2024

Hi @MrOxMasTer -- does the modal close for you if you add a @navigation/page.tsx component that returns null? If you're navigating to the index route, it's going to try and match @navigation/page.tsx rather than @navigation/[...catchAll] ([...catchAll] would apply to /foo, /foo/bar, but not /).

I can see how the docs are a bit unclear here, so I'll get those updated.

@MrOxMasTer
Copy link
Author

Hi @MrOxMasTer -- does the modal close for you if you add a @navigation/page.tsx component that returns null? If you're navigating to the index route, it's going to try and match @navigation/page.tsx rather than @navigation/[...catchAll] ([...catchAll] would apply to /foo, /foo/bar, but not /).

I can see how the docs are a bit unclear here, so I'll get those updated.

I deleted page.tsx to check, but it was there before and also didn't work on 14.2.3.

@MrOxMasTer
Copy link
Author

Hi @MrOxMasTer -- does the modal close for you if you add a @navigation/page.tsx component that returns null? If you're navigating to the index route, it's going to try and match @navigation/page.tsx rather than @navigation/[...catchAll] ([...catchAll] would apply to /foo, /foo/bar, but not /).

I can see how the docs are a bit unclear here, so I'll get those updated.

I read your comment about this and about the suggestion to support [[...catchAll]] in special routes and so also tried your way but it doesn't work still

@MrOxMasTer
Copy link
Author

image

@ztanner
Copy link
Member

ztanner commented Apr 26, 2024

Hi @MrOxMasTer -- does the modal close for you if you add a @navigation/page.tsx component that returns null? If you're navigating to the index route, it's going to try and match @navigation/page.tsx rather than @navigation/[...catchAll] ([...catchAll] would apply to /foo, /foo/bar, but not /).
I can see how the docs are a bit unclear here, so I'll get those updated.

I deleted page.tsx to check, but it was there before and also didn't work on 14.2.3.

I tried your provided reproduction and it works fine if I add a app/@modal/page.tsx component that returns null.

CleanShot.2024-04-26.at.14.05.12.mp4

Please provide an updated reproduction for us to look into this for you. Thanks!

@MrOxMasTer
Copy link
Author

Please provide an updated reproduction for us to look into this for you. Thanks!

So, I deleted the .next folder and ran it again and it worked!

Then let me ask you another question. Do I understand correctly that in this situation it can only lead to the home page? It seems logical, because the link is to the main page, but maybe somehow it can be realised by intercepts?

Because when testing on other pages, it doesn't return to the main page all the time.

@vercel vercel locked and limited conversation to collaborators Apr 26, 2024
@ztanner ztanner converted this issue into discussion #65100 Apr 26, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Issue was opened via the bug report template. Parallel & Intercepting Routes Related to Parallel and/or Intercepting routes.
Projects
None yet
Development

No branches or pull requests

2 participants