HistoryStateChangeEvent doesnt listen to .navigate()

Im having a trouble trying to listen every route change using HistoryStateChangeEvent.
I need to do something everytime before I navigate but it only listen to changes on the browser’s buttons navigation and on my header navigation (with RouterLinks). But it doesnt listen to the navigation using UI.getCurrent().navigate(AnotherViewClass.class); in other View Classes.

I created this in the MainView:

History history = UI.getCurrent().getPage().getHistory();
history.setHistoryStateChangeHandler(this::onHistoryStateChange);

private void onHistoryStateChange(HistoryStateChangeEvent event) {
    // Do something
}

Am I missing something to achieve what I want?

PS.: I know that there is a way using BeforeLeave or BeforeEnter events, but they dont solve my entire problem.

Sorry for any bad english.