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

[NEXT-1166] Modal Interception does not work for (.)[dynamic] routes #49614

Closed
1 task done
khuezy opened this issue May 10, 2023 · 17 comments · Fixed by #51526
Closed
1 task done

[NEXT-1166] Modal Interception does not work for (.)[dynamic] routes #49614

khuezy opened this issue May 10, 2023 · 17 comments · Fixed by #51526
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked

Comments

@khuezy
Copy link
Contributor

khuezy commented May 10, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.14.0
      npm: 9.3.1
      Yarn: 1.22.19
      pnpm: 7.27.0
    Relevant packages:
      next: 13.4.2-canary.4
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue

https://codesandbox.io/p/sandbox/youthful-butterfly-l44fsy

To Reproduce

  1. Go to sandbox and run the dev server.
  2. Click on the "Photos" link
  3. Click on "Go to /photos/[author]/[id]", where the author and id is "john/123"
  4. The interception does not work, the [author] params is "(.)john"
  5. Reload the page, the [author] params is "john"

Now go back to the root and click on the "Static" link. This route doesn't use dynamic routes and the interception works as expected.

Describe the Bug

When using dynamic routes in the modal, the interception of the current route does not work.
That is, when I'm on the "/photos" page, I want a modal-ize "/photos/[author]/[id]"

Expected Behavior

When on the "/photos" page, clicking on a child route should intercept the child modal.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-1166

@khuezy khuezy added the bug Issue was opened via the bug report template. label May 10, 2023
@abusada
Copy link
Contributor

abusada commented May 11, 2023

I've been facing similar issue, it seems that using:

(...) to match segments from the root app directory.

Fixes it. see here https://codesandbox.io/p/sandbox/quizzical-cloud-oj5kkw

@khuezy
Copy link
Contributor Author

khuezy commented May 11, 2023

@abusada Thanks! That should unblock me for now.

@Manduro
Copy link

Manduro commented May 11, 2023

Looks like a duplicate of #48143.

Using the (...) as a workaround only helps if your root segment is not dynamic.

@khuezy
Copy link
Contributor Author

khuezy commented May 11, 2023

Is it really a duplicate? The title says that (...)[dynamic] does not work, but it works in latest canary.
The issue here is that (.)[dynamic] doesn't work

@khuezy khuezy changed the title Modal Interception does not work for dynamic routes Modal Interception does not work for (.)[dynamic] routes May 11, 2023
@khuezy
Copy link
Contributor Author

khuezy commented May 11, 2023

I'm getting errors on rsc using (...) :/ EDIT: nvm, it was due to me using a custom Link component

@timneutkens timneutkens added the linear: next Confirmed issue that is tracked by the Next.js team. label May 17, 2023
@timneutkens timneutkens changed the title Modal Interception does not work for (.)[dynamic] routes [NEXT-1166] Modal Interception does not work for (.)[dynamic] routes May 17, 2023
@Nithur-M
Copy link

Looks like a duplicate of #48143.

Using the (...) as a workaround only helps if your root segment is not dynamic.

Yes, any updates on this one?
I am using dynamic routes as my root and facing this issue.

@Nithur-M
Copy link

I've been facing similar issue, it seems that using:

(...) to match segments from the root app directory.

Fixes it. see here https://codesandbox.io/p/sandbox/quizzical-cloud-oj5kkw

Hello, @abusada is it possible to use intercepting routes without using a folder to bind everything? I just want to display all the authors on the homepage without using /photo route

@Morishiri
Copy link

Originaly posted in the other linked issue, but seems it better fits here:

I also observed that having just dynamic [locale] in the root of my tree and trying to achieve NextGram behavior sometimes loads photo in modal, sometimes in regular page (didn't found a rule for it, looks like some race). May be related to this issue.

@Nickman87
Copy link

I am having a similar issue, repo for testing is here: https://codesandbox.io/p/sandbox/nextjs-intercepting-routes-s9j6mo?file=%2Fpackage.json%3A17%2C29

Checked with latest canary (13.4.5-canary.3) and still present
@feedthejim

@alejandrodev-vn
Copy link

alejandrodev-vn commented Jun 4, 2023

I also had the same problem:

Before I used folder [lang] to wrap: work

image

After I use folder [lang] to wrap: not work

image
Any fix this?

@thomasschwinn
Copy link

I have the same problem, with dynamic the root folder, intercepting does not work

@kodiakhq kodiakhq bot closed this as completed in #51526 Jun 22, 2023
kodiakhq bot pushed a commit that referenced this issue Jun 22, 2023
### What?
Paths with interception markers adjacent to dynamic segments are not correctly parsed, which leads to the path match logic failing. 

### Why?
`getParametrizedRoutes` checks for brackets but isn't expecting to receive an interception marker. For example, a path of `/photos/(.)[author]/[id]` results in the following regex:
`/^\/photos\/\(\.\)\[author\]\/([^/]+?)(?:\/)?$/`

This will not match a path of `/photos/(.)zack/1` since it retained the `[author]` brackets.

`getSegmentParam` has a similar issue when getting values for path params, though we can just skip the interception markers and go straight to the params.

Closes NEXT-1166, NEXT-1013
Fixes #48143
Fixes #49614

link NEXT-1013
@kloczewiak
Copy link

I don't think this got completely fixed by #51526
It only fixed it if you have nested dynamic routes like @modal/(.)[user]/[id]/page.tsx.
Something like @modal/(.)[author]/page.tsx still doesn't work.
Code sandbox forked from OP's example: https://codesandbox.io/p/sandbox/trusting-cray-fxlqlp?file=%2Fpackage.json%3A13%2C30

Should I create a new Issue?

@tuandev777
Copy link

I also had the same problem:

Before I used folder [lang] to wrap: work

image

After I use folder [lang] to wrap: not work

image Any fix this?

I got the same error with locale, have anyone try it yet ?

@Netail
Copy link
Contributor

Netail commented Jul 12, 2023

Facing the same issue with the following structure; (v13.4.9)

.
└── [locale]/
    ├── (program)/
    │   ├── programma/
    │   │   └── [slug]/
    │   │       └── [id]/
    │   │           └── page.jsx
    │   └── program/
    │       └── [slug]/
    │           └── [id]/
    │               └── page.jsx
    ├── @modal/
    │   ├── (.)programma/
    │   │   └── [slug]/
    │   │       └── [id]/
    │   │           └── page.jsx
    │   └── (.)program/
    │       └── [slug]/
    │           └── [id]/
    │               └── page.jsx
    └── layout.jsx

And the locale param become undefined

@khuezy
Copy link
Contributor Author

khuezy commented Jul 12, 2023

It might be best to open a new issue w/ the examples.

@kloczewiak
Copy link

It might be best to open a new issue w/ the examples.

It turns out there's already #52533
Please forward future discussion to that issue

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. 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 Aug 12, 2023
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. linear: next Confirmed issue that is tracked by the Next.js team. locked
Projects
None yet
Development

Successfully merging a pull request may close this issue.