fix: dialog remounting on className updates (#7224)
This commit is contained in:
parent
81c0259041
commit
d8166d9e1d
@ -17,9 +17,13 @@ export const useCreatePortalContainer = (opts?: {
|
|||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (div) {
|
if (div) {
|
||||||
|
div.className = "";
|
||||||
|
div.classList.add("excalidraw", ...(opts?.className?.split(/\s+/) || []));
|
||||||
div.classList.toggle("excalidraw--mobile", device.isMobile);
|
div.classList.toggle("excalidraw--mobile", device.isMobile);
|
||||||
|
div.classList.toggle("excalidraw--mobile", isMobileRef.current);
|
||||||
|
div.classList.toggle("theme--dark", theme === "dark");
|
||||||
}
|
}
|
||||||
}, [div, device.isMobile]);
|
}, [div, theme, device.isMobile, opts?.className]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const container = opts?.parentSelector
|
const container = opts?.parentSelector
|
||||||
@ -32,10 +36,6 @@ export const useCreatePortalContainer = (opts?: {
|
|||||||
|
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
|
|
||||||
div.classList.add("excalidraw", ...(opts?.className?.split(/\s+/) || []));
|
|
||||||
div.classList.toggle("excalidraw--mobile", isMobileRef.current);
|
|
||||||
div.classList.toggle("theme--dark", theme === "dark");
|
|
||||||
|
|
||||||
container.appendChild(div);
|
container.appendChild(div);
|
||||||
|
|
||||||
setDiv(div);
|
setDiv(div);
|
||||||
@ -43,7 +43,7 @@ export const useCreatePortalContainer = (opts?: {
|
|||||||
return () => {
|
return () => {
|
||||||
container.removeChild(div);
|
container.removeChild(div);
|
||||||
};
|
};
|
||||||
}, [excalidrawContainer, theme, opts?.className, opts?.parentSelector]);
|
}, [excalidrawContainer, opts?.parentSelector]);
|
||||||
|
|
||||||
return div;
|
return div;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user