From b07aa6e20594c8a57197925bf5d4021342fbf8fe Mon Sep 17 00:00:00 2001 From: David Luzar Date: Mon, 20 Jul 2020 12:53:53 +0200 Subject: [PATCH] delay scene init until document active (#1920) * delay scene init until document active * use opts.once for the listener --- src/components/App.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/App.tsx b/src/components/App.tsx index 5c8c0df8..be3b2c99 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -474,6 +474,14 @@ class App extends React.Component { window.history.replaceState({}, "Excalidraw", window.location.origin); } } else { + // https://github.com/excalidraw/excalidraw/issues/1919 + if (document.hidden) { + window.addEventListener("focus", () => this.initializeScene(), { + once: true, + }); + return; + } + isCollaborationScene = false; window.history.replaceState({}, "Excalidraw", window.location.origin); }