Skip to content

Commit

Permalink
Modify routing event handling to do nothing if navigation is cancelled (
Browse files Browse the repository at this point in the history
#200)

Co-authored-by: Jean-François Chaput <[email protected]>
  • Loading branch information
jfcartkeep and jfcartkeep authored Oct 2, 2023
1 parent 50b6918 commit deb1e37
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 @@ -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);
}
});
}
}
}

Expand Down

0 comments on commit deb1e37

Please sign in to comment.