Skip to content

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

@kevinkendzia

Description

@kevinkendzia

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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    ✅ Closed

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions