Selaa lähdekoodia

delay scene init until document active (#1920)

* delay scene init until document active

* use opts.once for the listener
David Luzar 5 vuotta sitten
vanhempi
commit
b07aa6e205
1 muutettua tiedostoa jossa 8 lisäystä ja 0 poistoa
  1. 8 0
      src/components/App.tsx

+ 8 - 0
src/components/App.tsx

@@ -474,6 +474,14 @@ class App extends React.Component<ExcalidrawProps, AppState> {
           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);
       }