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-1013] (...)[dynamic] does not work #48143

Closed
1 task done
sandervspl opened this issue Apr 8, 2023 · 10 comments · Fixed by #51526
Closed
1 task done

[NEXT-1013] (...)[dynamic] does not work #48143

sandervspl opened this issue Apr 8, 2023 · 10 comments · Fixed by #51526
Assignees
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked

Comments

@sandervspl
Copy link

sandervspl commented Apr 8, 2023

Verify canary release

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

Provide environment information

$ next info

    Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.12.1
      npm: 8.19.2
      Yarn: 1.22.19
      pnpm: 8.1.1
    Relevant packages:
      next: 13.3.1-canary.3
      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)

App directory (appDir: true)

Link to the code that reproduces this issue

https://github.com/sandervspl/intercept-route-test/

To Reproduce

  1. Go to https://intercept-route-test.vercel.app/en/foo/bar/baz
  2. Click on Show user
  3. It will show the regular page which says I am a REGULAR user page

Describe the Bug

You can not use a dynamic parameter with parallel routes, e.g. (...)[locale]

Expected Behavior

It should show a page with the text User INTERCEPT page

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-1013

@sandervspl sandervspl added the bug Issue was opened via the bug report template. label Apr 8, 2023
@github-actions github-actions bot added the area: app App directory (appDir: true) label Apr 8, 2023
@shawshankkumar
Copy link

It would help if you could deploy this!

@sandervspl
Copy link
Author

@kristian240
Copy link
Contributor

@feedthejim Can you take a look at this one as well? I also have an issue with this one.

@feedthejim
Copy link
Contributor

on the latest canary?

@sandervspl
Copy link
Author

@feedthejim I have just updated the deployed reproduction to canary.6 https://intercept-route-test.vercel.app/en/foo/bar/baz

@feedthejim feedthejim changed the title (...)[dynamic] does not work [NEXT-1013] (...)[dynamic] does not work Apr 14, 2023
@feedthejim feedthejim added the linear: next Confirmed issue that is tracked by the Next.js team. label Apr 14, 2023
@feedthejim
Copy link
Contributor

thanks for the repro @sandervspl, will investigate

@Manduro
Copy link

Manduro commented May 11, 2023

When looking into this with routes as below, I found that the interception route is never used. Instead it always uses the normal /language/[id] route and resolves the id param to (.)74a84042-7f87-43cf-8189-11da75c7afb3 (so including the (.) indicator).

{
	"/[language]/[id]/page": "/[language]/[id]",
	"/[language]/@modal/(.)[id]/page": "/[language]/(.)[id]"
}

So the problem likely lies in the route matching area. An interception segment should get priority over a normal dynamic segment.

Hope this helps @feedthejim

@Manduro
Copy link

Manduro commented May 11, 2023

Attached is a patch with a partial workaround for this issue. It's for (.)[dynamic] specifically, but can be updated to work with (...)[dynamic]. The param value will contain the (.), so you should replace this in your code that is using the param. And now the non-intercepted route is no longer working 😢

next+13.4.1.patch

@Morishiri
Copy link

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.

@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
@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 Jul 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: app App directory (appDir: true) 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.

6 participants