hilla
hilla copied to clipboard
createMenuItems includes parameterized routes
Describe the bug
The menu items created by createMenuItems includes paths with parameters, leading to links like users/{id}/edit in the menu
Expected-behavior
Only paths without parameters are shown
Reproduction
Create the following structure in a Hilla starter users/{id}/edit.tsx
System Info
Hilla 24.4.0.alpha25
@Legioth, @platosha, do I understand correctly that we don't want have these items exist in index.html response? I mean, I can remove them on the server level, so the Vaadin.server.views won't have it at all. Or I can filter them on createMenuItems level, keeping them available for the future.
We are planning to add support for an automatic main menu also for Flow layouts and we wouldn't want to have parameterized Hilla routes in the Flow menu either. From this follows that it would be preferable to filter them out before reaching index.html (i.e. either in Java or the Vite plugin).
I believe the views with optional parameters should have chance of appearing in the menu. Maybe, the createMenuItems can include them and let the users filter them out on demand?
Views with optional parameters should be in the menu except if excluded using the regular mechanism. It's only the ones with required parameters that must be left out since we cannot even generate a valid URL to such a view without knowing a parameter value.
This is still broken in 24.4.0.rc1 with the same exact steps as in the initial issue description
Seems like this is "only" broken for the case when the parameter is in the directory name.
views/test/{id}.tsx does not show up in the menu but views/users/{id}/edit.tsx does.
Note that the problematic view also gets a (invalid) link in the dev mode 404 view. I suspect that's caused by the same root cause. If that's not the case, then we should fix only the menu issue right away and then fix the 404 page issue separately with lower priority.