flow icon indicating copy to clipboard operation
flow copied to clipboard

React Router blocks navigation to the current view

Open knoobie opened this issue 1 year 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

React Router behaves in a different way than our Vaadin Router in that case. But nevertheless, this is a bug as the Flow navigation does not happens as it did with Vaadin Router. We have to investigate, meanwhile the workaround may be to fallback to Vaadin Router unfortunately.

mshabarov avatar Jul 02 '24 10:07 mshabarov

Created a BFP (VS-5299) for this (just in case Jira has problems)

knoobie avatar Jul 08 '24 07:07 knoobie

The issue was triaged and currently added to the backlog priority queue for further investigation

mcollovati avatar Jul 09 '24 10:07 mcollovati

This ticket/PR has been released with Vaadin 24.4.9.

vaadin-bot avatar Aug 19 '24 11:08 vaadin-bot