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

refreshCurrentRoute(true) doesn't work on forward or reroute #20988

Open
kevinkendzia opened this issue Feb 12, 2025 · 0 comments
Open

refreshCurrentRoute(true) doesn't work on forward or reroute #20988

kevinkendzia opened this issue Feb 12, 2025 · 0 comments

Comments

@kevinkendzia
Copy link

Description of the bug

Calling UI.getcurrent().refreshCurrentRoute() is supposed to rebuild the current route-target and optionally the whole layout-chain, see parameter refreshRouteChain, but if I use it to refresh a route that triggers a redirect (forward/reroute) in beforeEnter() vaadin seems to discard any new created route-component (including layouts) and reuse previous.

I think the problem is, that in
com.vaadin.flow.router.internal.AbstractNavigationStateRenderer.forward(NavigationEvent, BeforeEvent) and com.vaadin.flow.router.internal.AbstractNavigationStateRenderer.reroute(NavigationEvent, BeforeEvent)
the flags "forceInstantiation" and "recreateLayoutChain" of the current NavigationEvent aren't propagated to the new NavigationEvent created by
com.vaadin.flow.router.internal.AbstractNavigationStateRenderer.getNavigationEvent(NavigationEvent, BeforeEvent)

Expected behavior

The route-chain should also be refreshed/recreated if a redirect was triggered inside beforeEnter() of the route-target.

Minimal reproducible example

testrefreshroute.zip

  1. Start the Project & open in Browser
  2. Click "Option 1"

Attributes in the Session are set:

  • test_attribute = value shown in header/appbar
  • redirect = flag evaluated in beforeEnter() to trigger redirect
    and then refreshCurrentRoute(true) is called (true = refreshRouteChain)

Expected:
header/appbar shows h2 with text "OPTION 1" but nothing shows

Button "Option 2" shows how it should work (= shows Text "OPTION 2" in header/appbar) but without redirects.

Versions

  • Vaadin / Flow version: 24.6.5
  • Java version: 17
  • OS version: Windows 11
  • Browser version (if applicable): Version 132.0.6834.160 (Offizieller Build) (64-Bit)
  • Application Server (if applicable): Springboot/Embedded Tomcat
  • IDE (if applicable): Eclipse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔖 Normal Priority (P2)
Status: 🅿️Parking lot
Development

No branches or pull requests

2 participants