Unmount on pagehide instead of beforeunload

It seems cluster onbeforeunload is not triggered when iframe is removed from dom by the parent (when disconnecting a cluster).

While on root/main frame the beforeunload event does work, it seems to be adviced to use pagehide instead.

Signed-off-by: Sami Tiilikainen <97873007+samitiilikainen@users.noreply.github.com>
This commit is contained in:
Sami Tiilikainen committed 2023-01-30 14:10:05 +02:00
1 parent e1da883c9a
commit 528e18e99e
2 files changed
+2 -2

No files matched your search

@@ -73,7 +73,7 @@ export const initClusterFrame = ({
});
});
window.onbeforeunload = () => {
window.onpagehide = () => {
logger.info(
`${logPrefix} Unload dashboard, clusterId=${(hostedCluster.id)}, frameId=${frameRoutingId}`,
);
@@ -57,7 +57,7 @@ const initRootFrameInjectable = getInjectable({
registerIpcListeners();
window.addEventListener("beforeunload", () => {
window.addEventListener("pagehide", () => {
logger.info("[ROOT-FRAME]: Unload app");
unmountRoot();