-
Notifications
You must be signed in to change notification settings - Fork 176
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
Router throws exception when navigating between PermitAll and AnonymousAllowed views #20939
Comments
Looks like a Flow issue |
@Artur- What does copilot do/call when the route in the |
It should be a standard link, nothing special |
If I add a public view with a standard like ( However, when clicking the link on the Copilot panel, I can see several navigation requests from the client. |
@Artur- did I get it right that the link on the Copilot panel is not a "normal" link, but it emits an event on the event bus that is handled with |
It certainly seems so. I wonder why |
I did a test replacing the code in the event bus |
Yes, the Copilot code as it is currently looks like some workaround for earlier React router integration issues in Flow. I don't know if
is supposed to be a valid way to navigate, but it should not be needed for Copilot either |
Dispatching a |
A normal anchor should work, but it looks like that currently the listener that intercept clicks on anchors is registered only when Flow is initialized. |
Is Vaadin router affected by the same issue? EDIT: Looks like vaadin-router registers the listener in the constructor (https://github.com/vaadin/router/blob/main/src/router.ts#L157), so it probably works out-of-the-box (to be tested). https://github.com/vaadin/router/blob/main/src/triggers/click.ts |
From Copilot point of view it is irrelevant as Vaadin router is not supported |
When using React router, clicks on anchors are intercepted only if Flow client has been initialized. In Hilla or hybrid application, if a Flow view is never navigated, clicking on such links cause the browser to reload the page instead of navigating to the expected view. This change registers a global click handler that intercepts click events and triggers a router navigation if necessary. The new behavior is aligned with vaadin-router. Fixes #20939
When using React router, clicks on anchors are intercepted only if Flow client has been initialized. In Hilla or hybrid application, if a Flow view is never navigated, clicking on such links cause the browser to reload the page instead of navigating to the expected view. This change registers a global click handler that intercepts click events and triggers a router navigation if necessary. The new behavior is aligned with vaadin-router. Fixes #20939
Description of the bug
I have two views one is anonymous allowed, the other one requires login. When I try to navigate from anonymous to another one, a console errors are logged
Screen.Recording.2025-02-03.at.14.32.58.mov
.
Expected behavior
There should not be any console errors.
Minimal reproducible example
Create two views as below. Activate Copilot and click the links in Views & Routes panel
LoggedInOnly.java
LoginView.java
Versions
Hilla: 24.7.0.alpha9
Flow: 24.7.0.alpha9
Vaadin: 24.7.0.alpha6
Spring Boot: 3.4.2
Spring: 6.2.2
Spring Security: Enabled
Copilot: 24.7-SNAPSHOT
Frontend Hotswap: Enabled, using Vite
OS: aarch64 Mac OS X 14.7.1
Java: JetBrains s.r.o. 21.0.5
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Java Hotswap: Java Hotswap is enabled
IDE Plugin: 1.4.6 IntelliJ
The text was updated successfully, but these errors were encountered: