Prevent browser back behavior

Hello,

Using the Jmix 2.1, I would like to prevent browser back button from navigating to the previous view, especially going back from the main application window to the login screen.

I have tried creating an event listener bean as follows:

package com.company.app.listener;

import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.page.History;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component("company_HistoryChangedListener")
public class HistoryChangedListener {

    public History history;

    @EventListener
    public void historyChangedHandler(final History.HistoryStateChangeEvent event) {
        (event.getSource()).pushState(null, event.getLocation());
        history.go(1);
    }
}

or

(UI.getCurrent()).getPage().executeJs("history.pushState(null, null, location.href); window.onpopstate = function () {history.go(1);};");

also at various places such as AfterClose, but without results.

Kind regards,
Mladen