React Router blocks navigation to the current view
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.
- Click prints (when I wanna enter the route for the first time):
Was I called 0?
Was I called 1?
Was I called 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.
- Click prints (when I wanna enter the route for the first time):
Was I called 0?
Was I called 1?
Was I called 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
- Vaadin / Flow version: 24.4.x
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.
Created a BFP (VS-5299) for this (just in case Jira has problems)
The issue was triaged and currently added to the backlog priority queue for further investigation
This ticket/PR has been released with Vaadin 24.4.9.