From ec7341e08e09565c15ab787568a070c589817c5b Mon Sep 17 00:00:00 2001 From: Brandon Ferrari Date: Tue, 13 Jun 2023 11:05:38 -0400 Subject: [PATCH 1/2] added fix for handle routing event when navigation is cancelled --- package.json | 2 +- src/browser/constructLayoutEngine.js | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 4b8e509..5794c68 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "single-spa-layout", - "version": "2.1.0", + "version": "2.1.1", "description": "Layout engine for single-spa applications", "main": "dist/umd/single-spa-layout.min.cjs", "module": "dist/esm/single-spa-layout.min.js", 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); + } + }); + } } /** From 5ce19c864d35602ff511953647d4bfe8da1a76e8 Mon Sep 17 00:00:00 2001 From: Joel Denning Date: Wed, 14 Jun 2023 20:17:42 -0600 Subject: [PATCH 2/2] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5794c68..4b8e509 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "single-spa-layout", - "version": "2.1.1", + "version": "2.1.0", "description": "Layout engine for single-spa applications", "main": "dist/umd/single-spa-layout.min.cjs", "module": "dist/esm/single-spa-layout.min.js",