vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
618 stars 167 forks source link

Parametrized hilla view not shown with automatic flow Layout and flowLayout=false #20261

Open tltv opened 1 week ago

tltv commented 1 week ago

Description of the bug

Parametrized Hilla file route like frontend/views/products/{productId}.tsx shows "Could not navigate to 'products/1'" error page when navigating for example to /products/1 path with export const config: ViewConfig = { flowLayout: false }; in the tsx and project has Layout annotation to enable automatic flow layout for the route.

Expected behavior

Hilla view is shown without flow main layout.

Minimal reproducible example

Download my-app.zip, unpack and run it and navigate to http://localhost:8080/products/1

Versions

Hilla: 24.5.0.rc2 Flow: 24.5.0.rc2 / 24.5.0 Vaadin: 24.5.0.rc2 Copilot: 24.5.0.rc2 Frontend Hotswap: Enabled, using Vite OS: amd64 Windows 10 10.0 Java: JetBrains s.r.o. 17.0.11 Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Java Hotswap: Java Hotswap is enabled IDE Plugin: 1.3.3 IntelliJ

tltv commented 1 week ago

Maybe this has something to do in here in Hilla file-router. I noticed that in generated file-routes.ts all flowLayout flags are true for some reason. Tested to switch them to false in the generated file and that made view show up again. Could you check this out @caalador?

caalador commented 1 week ago

file-routes.ts gets true for all that have a possible layout (matching path in the layouts.json) and that true is overridden by the actual ViewConfig definition of the view.

caalador commented 1 week ago

One issue is that /products/:productId doesn't match /products/1 so we would need some template matching to the hasClientRoute check. The client side also seems to be quite tightly tide to the parent flowLayout state instead of the child state, so that would probably need some logic update so a child with flowLayout false is not going to the server when the parent has flowLayout true. Also mixed use layouts for instance "platform/hello" layout true and "platform/hilla" layout false woudl both use the layout that is in "platform" and not what they define.

caalador commented 1 week ago

Also on the file-routes.ts is you change only the createRoute("products", true, [ to createRoute("products", false, [ the parameterised route works, but not if you only change the child createRoute.

tltv commented 1 week ago

One issue is that /products/:productId doesn't match /products/1 so we would need some template matching to the hasClientRoute check.

That one needs a separate enhancement/bug ticket. Let's focus on the flowLayout=false issue here.