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

[File-Router] wildcard view is not matched if subdirectories with parameters in their name exist #3316

Open
taefi opened this issue Mar 3, 2025 · 4 comments
Labels
bug Something isn't working hilla Issues related to Hilla needs design

Comments

@taefi
Copy link
Contributor

taefi commented Mar 3, 2025

Describe the bug

There is a case for handling the wildcard route params that seems to be edgy and doesn't provide have a good DX.

With a directory structure like this:

/views
└── customers
|   ├── {id}
|   │   ├── edit.tsx
|   │   └── @index.tsx
|   ├── @index.tsx 
|   └── new.tsx
└── {...wildcard}.tsx

Due to the existence of the {id} directory under customers, navigating to the /customers/new/123 is not matched to the wildcard view at the root (under views), and will not match anything else either.

The workaround is to add another {…wildcard}.tsx under views/customers/{id} (and not under the view/customers/ because this is not get matched either).

Expected-behavior

With the described behaviour, for implementing a simple "Not Found" view, the users need to pollute the views subdirectories by adding many wildcard views (under each directory that has parameter directory such as {id}, which happens to be a common case).

I'd expect that the wildcard view defined under the root directory to handle all the non-matched routes.

Reproduction

Any project from the start with the above-mentioned view directory structure reproduces the issue.

System Info

Tested with 24.7.0.beta1

@taefi taefi added bug Something isn't working hilla Issues related to Hilla labels Mar 3, 2025
@platosha
Copy link
Contributor

Note: a top-level src/main/frontend/views/{...wildcard}.tsx will override Flow fallback. However, let's consider adding a 404 handler that takes server-side routes into account as a separate feature.

@platosha
Copy link
Contributor

We could reuse the logic we have for adding Flow fallback for the wildcards.

@platosha
Copy link
Contributor

During discussion, we realised that we need a better definition for the expected FS router behavior regarding various combinations of:

  • wildcard routes
  • layouts
  • server-side fallback
  • custom 404 handling

@platosha
Copy link
Contributor

Let's also consider behavior with #3344

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hilla Issues related to Hilla needs design
Projects
None yet
Development

No branches or pull requests

2 participants