We use History.replaceState to update url query parameters to reflect current view filter state.
In Vaadin 23 we do not get any navigation related event as we are not navigating anywhere as we are just updating the url state so that it represent the current view state.
After upgrading to Vaadin 24 we are now getting AfterNavigation events that in our code triggers the rebinding (not included in the example below) of the filter fields leading to unexpected behaviour as those happen while the user may be writing in the fields.
Expected behavior
No navigation event are triggered (as in vaadin 23) as we are just replacing the current history state and not doing any effective navigation.
Minimal reproducible example
@Route(value = "after-navigation")
public class AfterNavigationTestView extends VerticalLayout implements AfterNavigationObserver {
private static final long serialVersionUID = 1L;
private Location lastLocation = null;
public AfterNavigationTestView() {
TextField textField = new TextField();
textField.addValueChangeListener(e -> {
History history = UI.getCurrent().getPage().getHistory();
history.replaceState(null, new Location(lastLocation.getSegments(), QueryParameters.of("v", e.getValue())));
});
textField.setValueChangeMode(ValueChangeMode.LAZY);
add(textField);
}
@Override
public void afterNavigation(AfterNavigationEvent event) {
if (lastLocation != null) {
Notification.show("Unexpected after navigation");
}
lastLocation = event.getLocation();
}
}
Writing something in the TextField should not trigger afterNavigation
Description of the bug
We use History.replaceState to update url query parameters to reflect current view filter state. In Vaadin 23 we do not get any navigation related event as we are not navigating anywhere as we are just updating the url state so that it represent the current view state. After upgrading to Vaadin 24 we are now getting AfterNavigation events that in our code triggers the rebinding (not included in the example below) of the filter fields leading to unexpected behaviour as those happen while the user may be writing in the fields.
Expected behavior
No navigation event are triggered (as in vaadin 23) as we are just replacing the current history state and not doing any effective navigation.
Minimal reproducible example
Writing something in the TextField should not trigger afterNavigation
Versions