From ff028babe88c300f2ca8de7a216f6eae5b6989cc Mon Sep 17 00:00:00 2001
From: AlexRV12 <71396855+AlexRV12@users.noreply.github.com>
Date: Thu, 8 Oct 2026 09:30:37 +0200
Subject: [PATCH] close raw app preview pop-out when the editor tab reloads or
closes (#11607)
---
.../lib/components/raw_apps/RawAppEditor.svelte | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/frontend/src/lib/components/raw_apps/RawAppEditor.svelte b/frontend/src/lib/components/raw_apps/RawAppEditor.svelte
index d0d1b40de1..f708b97efe 100644
--- a/frontend/src/lib/components/raw_apps/RawAppEditor.svelte
+++ b/frontend/src/lib/components/raw_apps/RawAppEditor.svelte
@@ -1839,13 +1839,15 @@ addEventListener('message', function (e) {
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
- // re-feed it — a permanently blank orphan.
+ // 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
- })
+ }
+ onDestroy(closeExternalPreview)
function openExternalPreview() {
// Reuse an already-open window instead of spawning duplicates.
@@ -2512,7 +2514,7 @@ addEventListener('message', function (e) {
}
-
+
{