diff --git a/src/components/App.tsx b/src/components/App.tsx index 13386e6f32..f97a0a8c5e 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -197,9 +197,10 @@ import { actionToggleViewMode } from "../actions/actionToggleViewMode"; const IsMobileContext = React.createContext(false); export const useIsMobile = () => useContext(IsMobileContext); -const ExcalidrawContainerContext = React.createContext( - null, -); +const ExcalidrawContainerContext = React.createContext<{ + container: HTMLDivElement | null; + id: string | null; +}>({ container: null, id: null }); export const useExcalidrawContainer = () => useContext(ExcalidrawContainerContext); @@ -244,6 +245,10 @@ class App extends React.Component { public libraryItemsFromStorage: LibraryItems | undefined; private id: string; private history: History; + private excalidrawContainerValue: { + container: HTMLDivElement | null; + id: string; + }; constructor(props: AppProps) { super(props); @@ -300,6 +305,12 @@ class App extends React.Component { } readyPromise.resolve(api); } + + this.excalidrawContainerValue = { + container: this.excalidrawContainerRef.current, + id: this.id, + }; + this.scene = new Scene(); this.library = new Library(this); this.history = new History(); @@ -327,7 +338,7 @@ class App extends React.Component { if (viewModeEnabled) { return ( { } return ( { } > { }; public async componentDidMount() { + this.excalidrawContainerValue.container = this.excalidrawContainerRef.current; + if ( process.env.NODE_ENV === ENV.TEST || process.env.NODE_ENV === ENV.DEVELOPMENT diff --git a/src/components/Dialog.tsx b/src/components/Dialog.tsx index ada1bb5a60..79cebf7e74 100644 --- a/src/components/Dialog.tsx +++ b/src/components/Dialog.tsx @@ -2,7 +2,7 @@ import clsx from "clsx"; import React, { useEffect, useState } from "react"; import { useCallbackRefState } from "../hooks/useCallbackRefState"; import { t } from "../i18n"; -import { useIsMobile } from "../components/App"; +import { useExcalidrawContainer, useIsMobile } from "../components/App"; import { KEYS } from "../keys"; import "./Dialog.scss"; import { back, close } from "./icons"; @@ -21,6 +21,7 @@ export const Dialog = (props: { }) => { const [islandNode, setIslandNode] = useCallbackRefState(); const [lastActiveElement] = useState(document.activeElement); + const { id } = useExcalidrawContainer(); useEffect(() => { if (!islandNode) { @@ -82,7 +83,7 @@ export const Dialog = (props: { theme={props.theme} > -

+

{props.title}