Umbraco.CMS.Backoffice icon indicating copy to clipboard operation
Umbraco.CMS.Backoffice copied to clipboard

[BUG]: Modal Route does not support navigation with browser history

Open enkelmedia opened this issue 10 months ago • 0 comments

I just notice that the behavior of the routed modal (UmbModalRouteRegistrationController) is quite strange when clicking on the "back"-button in the browser.

The route changes in the address bar and the view "behind" the modal is changing - but the modal is still on top of everything.

umb-modal-strange

In an ideal world there should be some kind of callback, like the onSetup(), onReject() to hook into the navigation and maybe prompt the user if "the thing" in the modal is not saved.

I played with some of the events from the router-slot library but the route still changed.

window.addEventListener("willchangestate", e => {

    // Check if we should navigate away from this page
    if (!confirm("You have unsafed data. Do you wish to discard it?")) {
        e.preventDefault();
        return;
    }

}, {once: true});

enkelmedia avatar Apr 05 '24 23:04 enkelmedia