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

Route with "" path does not show up with Hilla @layout.tsx #20869

Open
Artur- opened this issue Jan 16, 2025 · 5 comments
Open

Route with "" path does not show up with Hilla @layout.tsx #20869

Artur- opened this issue Jan 16, 2025 · 5 comments

Comments

@Artur-
Copy link
Member

Artur- commented Jan 16, 2025

Description of the bug

If you have only @layout.tsx and one Flow view with @Route("") then the view is not shown.

Expected behavior

The view is shown

Minimal reproducible example

% npm init vaadin@latest                                                    

> npx
> create-vaadin

✔ Project name: … hilla-layout
✔ Example views: › Hilla (React + TypeScript)
✔ Features: › Use pre release

remove @index.tsx and any other client side view. Leave @layout.tsx.

Add a flow view with @Route("")

If you add one Hilla view, or leave the created about-hilla.tsx in the views folder, then the Flow view works

Versions

  • Vaadin / Flow version: 24.7-SNAPSHOT
@Jusius
Copy link

Jusius commented Jan 22, 2025

yup i found this issue when updating to vaadin 24.6.0
the work around is adding the @index.tsx in the frontend/views/ folder

place the route link on this index.tsx

@tepi tepi self-assigned this Jan 22, 2025
@tepi tepi moved this from 🪵Product backlog to ⚒️ In progress in Vaadin Flow ongoing work (Vaadin 10+) Jan 22, 2025
@tepi
Copy link
Contributor

tepi commented Feb 3, 2025

Looks like none of Flow's client side navigation logic is triggered in this case at all. Could not yet find the root cause for this.

@tepi tepi removed their assignment Feb 3, 2025
@tepi tepi moved this from ⚒️ In progress to 🟢Ready to Go in Vaadin Flow ongoing work (Vaadin 10+) Feb 3, 2025
@Jusius
Copy link

Jusius commented Feb 3, 2025

is it possible the issue lies on the hilla side ?

The reason I'm asking for a minimal project that shows the problem is that the FS-based routing is heavily based on convention-over-configuration, e.g. suggesting a file containing the layout should be named as @layout.tsx to be picked up by the FS Router. Now, in 24.6, Flow support for automatic Java layouts is added, so it means there's a chance that something in you project may not be as the framework expects.

i got this response from @taefi when i open the Issues on hilla

@tepi
Copy link
Contributor

tepi commented Feb 3, 2025

That's very possible. Unfortunately our documentation does not seem to describe this specific case, so I can't really say if it should work or not. To me it seems like a valid case though.

@mcollovati
Copy link
Collaborator

The issue could be that when there are no Hilla views but a @layout, the routes object built by RouterConfigurationBuilder has an entry for blank path, but without children, so it does not fallback to Flow.

routes object without Hilla view
[
 {
     "path": "",
     "element": {
         "key": null,
         "ref": null,
         "props": {},
         "_owner": null,
         "_store": {}
     },
     "handle": {
         "title": "Main Layout"
     }
 },
 {
     "path": "*",
     "element": {
         "key": null,
         "ref": null,
         "props": {},
         "_owner": null,
         "_store": {}
     }
 }
]

But if you add a Hilla view, then the blank path entry, in addition to the Hilla view, has an entry for * and another one with "index": true.

routes object with Hilla view
[
 {
     "path": "",
     "element": {
         "key": null,
         "ref": null,
         "props": {},
         "_owner": null,
         "_store": {}
     },
     "children": [
         {
             "path": "hilla",
             "element": {
                 "key": null,
                 "ref": null,
                 "props": {},
                 "_owner": null,
                 "_store": {}
             },
             "handle": {
                 "title": "hilla"
             }
         },
         {
             "path": "*",
             "element": {
                 "key": null,
                 "ref": null,
                 "props": {},
                 "_owner": null,
                 "_store": {}
             }
         },
         {
             "index": true,
             "element": {
                 "key": null,
                 "ref": null,
                 "props": {},
                 "_owner": null,
                 "_store": {}
             }
         }
     ],
     "handle": {
         "title": "Main Layout"
     }
 },
 {
     "path": "*",
     "element": {
         "key": null,
         "ref": null,
         "props": {},
         "_owner": null,
         "_store": {}
     }
 },
 {
     "index": true,
     "element": {
         "key": null,
         "ref": null,
         "props": {},
         "_owner": null,
         "_store": {}
     }
 }
]

If this is confirmed, the issue should be moved to the Hilla repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔖 Normal Priority (P2)
Status: 🟢Ready to Go
Development

No branches or pull requests

5 participants