flow icon indicating copy to clipboard operation
flow copied to clipboard

React Router blocks navigation to the current view

Open knoobie opened this issue 2 weeks ago • 1 comments

Description of the bug

When I click on a link that targets the current page no server-side round-trip takes place and no navigation events are triggered.

  1. Click prints (when I wanna enter the route for the first time):
Was I called 0?
Was I called 1?
Was I called 2?
  1. Click prints (when I'm already on the route):

Expected behavior

Like in previous versions: The Navigation Observer gets triggered so that I can "reload" the page for people clicking the same link in a menu.

  1. Click prints (when I wanna enter the route for the first time):
Was I called 0?
Was I called 1?
Was I called 2?
  1. Click prints (when I'm already on the route):
Was I called 1?
Was I called 2?

Minimal reproducible example

@Route(value = "test", layout = MainLayout.class) // Your Main Layout of choice where you place a router link to this view
public class TestView extends Div implements BeforeEnterObserver, AfterNavigationObserver {

  public TestView() {
    System.out.println("Was I called 0?");
  }

  @Override
  public void beforeEnter(BeforeEnterEvent event) {
    System.out.println("Was I called 1?");
  }

  @Override
  public void afterNavigation(AfterNavigationEvent afterNavigationEvent) {
    System.out.println("Was I called 2?");
  }
}

Versions

  • Vaadin / Flow version: 24.4.x

knoobie avatar Jun 25 '24 15:06 knoobie