Page().setLocation does not call BeforeLeaveObserver/AfterNavigationObserver

I use URL navigation with UI.getCurrent().navigate(Class navigationTarget, RouteParameters parameters). Everything works fine. And by fine I mean that the current Components receive BeforeLeaveObserver and AfterNavigationObserver events.

But when I use UI.getCurrent().getPage().setLocation(newUrl), then the current Components receive no events at all. Ditto page.open(url).

Since there is a solution (do it the way that works), this is just an FYI. Just wanted to note the issue.

Rich MacDonald

Hi, There is already a issue about it here: BeforeLeaveObserver not usable for the proposed purpose · Issue #14499 · vaadin/flow · GitHub

1 Like