close raw app preview pop-out when the editor tab reloads or closes (#11607)

This commit is contained in:
AlexRV12
2026-10-08 09:30:37 +02:00
committed by GitHub
parent 8b9222d778
commit ff028babe8
@@ -1839,13 +1839,15 @@ addEventListener('message', function (e) {
syncExternalPreviewNotice()
syncExternalPreview()
}
onDestroy(() => {
// Don't leave a detached preview behind when the editor unmounts: it
// would stop receiving builds and, once refreshed, has no opener to
// Don't leave a detached preview behind when the editor goes away, by
// unmounting or by its tab reloading or closing (`pagehide`, which skips
// `onDestroy`): it would stop receiving builds, and its document is a blob
// URL owned by this page, so refreshing it gives "not found".
function closeExternalPreview() {
if (externalPreviewWindow && !externalPreviewWindow.closed) externalPreviewWindow.close()
externalPreviewWindow = null
externalPreviewWindow = null
}
onDestroy(closeExternalPreview)
function openExternalPreview() {
@@ -2512,7 +2514,7 @@ addEventListener('message', function (e) {
}
}
</script>
<svelte:window onmessage={listener} onkeydown={handleKeydown} onpagehide={closeExternalPreview} />
<DarkModeObserver
bind:darkMode