From b0e1a425de447002a170fa9d7f14548493f27e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Chaput?= Date: Wed, 30 Aug 2023 11:43:54 -0400 Subject: [PATCH] Modify routing event handling to do nothing if navigation is cancelled --- src/browser/constructLayoutEngine.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/browser/constructLayoutEngine.js b/src/browser/constructLayoutEngine.js index 3d8630e..9db71f8 100644 --- a/src/browser/constructLayoutEngine.js +++ b/src/browser/constructLayoutEngine.js @@ -206,15 +206,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); + } + }); + } } }