diff --git a/src/browser/constructLayoutEngine.js b/src/browser/constructLayoutEngine.js index 8ccda22..af1dad8 100644 --- a/src/browser/constructLayoutEngine.js +++ b/src/browser/constructLayoutEngine.js @@ -204,15 +204,18 @@ export function constructLayoutEngine({ }); } - function handleRoutingEvent({ detail: { newUrl } }) { - getAppsToUnmount(newUrl).forEach((name) => { - const applicationElement = document.getElementById( - applicationElementId(name) - ); - if (applicationElement && applicationElement.isConnected) { - applicationElement.parentNode.removeChild(applicationElement); - } - }); + function handleRoutingEvent({ detail: { navigationIsCanceled, newUrl } }) { + // only unmount if navigation is not cancelled + if (!navigationIsCanceled) { + getAppsToUnmount(newUrl).forEach((name) => { + const applicationElement = document.getElementById( + applicationElementId(name) + ); + if (applicationElement && applicationElement.isConnected) { + applicationElement.parentNode.removeChild(applicationElement); + } + }); + } } /**