Skip to content

Commit

Permalink
Fix - Handle Routing Event - Don't Unmount If Navigation is Cancelled (
Browse files Browse the repository at this point in the history
…#190)

* added fix for handle routing event when navigation is cancelled

* Update package.json

---------

Co-authored-by: Brandon Ferrari <[email protected]>
Co-authored-by: Joel Denning <[email protected]>
  • Loading branch information
3 people authored Jun 15, 2023
1 parent 325f6ef commit eef6b1b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/browser/constructLayoutEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
}

/**
Expand Down

0 comments on commit eef6b1b

Please sign in to comment.