vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
588 stars 164 forks source link

React Router blocks navigation to the current view #19635

Open knoobie opened 3 days ago

knoobie commented 3 days ago

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?
  2. 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?
  2. 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