Open khuezy opened 1 month ago
Does this only happen during next dev
?
Update: this also happens on next start
.
Based on my investigation, here's what I found:
fsChecker.rewrites.beforeFiles
is the route matcher for interception routes.
/gallery/static
, it is converted to /gallery/(.)static
which matches with the interception route pattern of /gallery/(.)[dynamic]
.fsChecker.rewrites.beforeFiles
after the check_fs
matcher, it fixed this issue but introduces another major issue - interception routes are no longer given priority over exact fs
matches, meaning that if we want to intercept /gallery/a
and if that route exists as a static route, it will no longer be intercepted.This means that we have to do the following:
/gallery/(.)[dynamic]
, we have to check for an exact match on /gallery/<path>
. Similarly, if we intercept on /gallery/nested/(.)[dynamic]
, we have to check for an exact match on /gallery/nested/<path>
. During this process, we have to ensure that we do not match with /gallery/[dynamic]
or /gallery/nested/[dynamic]
- we have to look for an exact match in the fs
. We also have to take care of the (...)
interception pattern.This process introduces overhead during the route resolution step, and is also not straightforward to implement.
Given the current implementation, it is clear that interception routes are given priority over anything else, which makes sense, so this behaviour can be documented and we can explicitly mention in the docs that if the user wants to intercept a dynamic path parameter, we will perform greedy matching.
Thanks for your time investigating! If this isn't supported, then I can just move the dynamic route down a subpath.
I'm not a core contributor, so let's wait for someone from the core team to look at this issue. Let's see what happens.
I have these two pages:
src/app/@modal/(.)writer/drafts/[draft_id]/chapters/[chapter_id]/page.tsx
src/app/writer/drafts/[draft_id]/chapters/[chapter_id]/page.tsx
What would make the modal appear once clicking any link on the client-side. But instead it doesn't work. I tested on all the other subsequent routes and works:Moving the page to src/app/@modal/(.)writer/drafts/[draft_id]/chapters/page.tsx
Captures the transition and renders the modal.
As well on:
src/app/@modal/(.)writer/drafts/[draft_id]/page.tsx
src/app/@modal/(.)writer/drafts/page.tsx
src/app/@modal/(.)writer/page.tsx
All these examples works perfectly but as soon I add the page on the second dynamic route containing the "chapter_id" it stop to work.
There's any limitation on the API as how far nested the intercept would work or I'm doing something wrong?
Link to the code that reproduces this issue
https://github.com/khuezy/next-modal-bug
To Reproduce
Current vs. Expected behavior
Modal Interception intercepts static routes as dynamic.
When linking to
/gallery/static
, the modal interceptor intercepts it as/gallery/[dynamic]
.Without "@modal", the
/gallery/static
is processed before the/gallery/[dynamic]
route. But with "@modal" interception, it is intercepting the/gallery/static
path as[dynamic]
So with that, the expectation of "@modal" route interception is the same. "@modal" should not intercept static routes.
Provide environment information
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
No response