From 15bb902db343f3cda35ddfded60423ae798fbf03 Mon Sep 17 00:00:00 2001 From: dwelle <5153846+dwelle@users.noreply.github.com> Date: Sat, 29 Mar 2025 19:27:48 +0100 Subject: [PATCH] feat: allow to disable preventUnload in dev --- excalidraw-app/App.tsx | 8 +++++++- excalidraw-app/collab/Collab.tsx | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/excalidraw-app/App.tsx b/excalidraw-app/App.tsx index 60e9b3008..bb62a0e96 100644 --- a/excalidraw-app/App.tsx +++ b/excalidraw-app/App.tsx @@ -608,7 +608,13 @@ const ExcalidrawWrapper = () => { excalidrawAPI.getSceneElements(), ) ) { - preventUnload(event); + if (import.meta.env.VITE_APP_DISABLE_PREVENT_UNLOAD !== "true") { + preventUnload(event); + } else { + console.warn( + "preventing unload disabled (VITE_APP_DISABLE_PREVENT_UNLOAD)", + ); + } } }; window.addEventListener(EVENT.BEFORE_UNLOAD, unloadHandler); diff --git a/excalidraw-app/collab/Collab.tsx b/excalidraw-app/collab/Collab.tsx index f6f763041..98c66e425 100644 --- a/excalidraw-app/collab/Collab.tsx +++ b/excalidraw-app/collab/Collab.tsx @@ -301,7 +301,13 @@ class Collab extends PureComponent { // the purpose is to run in immediately after user decides to stay this.saveCollabRoomToFirebase(syncableElements); - preventUnload(event); + if (import.meta.env.VITE_APP_DISABLE_PREVENT_UNLOAD !== "true") { + preventUnload(event); + } else { + console.warn( + "preventing unload disabled (VITE_APP_DISABLE_PREVENT_UNLOAD)", + ); + } } });