Delay removing iframe to fix renderer crash (#6952)

Signed-off-by: Sebastian Malton <sebastian@malton.name>

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2023-01-17 08:55:52 -05:00
1 parent d3a3d7234a
commit 8ace84f7e7
1 file changed
+9 -1
@@ -88,7 +88,15 @@ export class ClusterFrameHandler {
() => {
this.dependencies.logger.info(`[LENS-VIEW]: remove dashboard, clusterId=${clusterId}`);
this.views.delete(clusterId);
parentElem.removeChild(iframe);
// Must only remove iframe from DOM after it unloads old code. Else it crashes
iframe.addEventListener("load", () => parentElem.removeChild(iframe), {
once: true,
});
// This causes the old code to be unloaded.
iframe.setAttribute("src", "");
dispose();
},
);