diff --git a/apps/web/src/components/chat/ChatCanvas.tsx b/apps/web/src/components/chat/ChatCanvas.tsx index 4df7ad66deb7..c66e42f0607f 100644 --- a/apps/web/src/components/chat/ChatCanvas.tsx +++ b/apps/web/src/components/chat/ChatCanvas.tsx @@ -7,6 +7,7 @@ import { type ComponentProps, type CSSProperties, } from "react"; +import { flushSync } from "react-dom"; import { ChatCanvasContext } from "./ChatCanvasContext"; import { resolveChatCanvasLayout, type ChatCanvasPreview } from "./chatCanvasLayout"; import type { PreviewMiniPlayerObstacles } from "../preview/previewMiniPlayerLayout"; @@ -90,7 +91,7 @@ export function ChatCanvas({ ); }; measure(); - const observer = new ResizeObserver(measure); + const observer = new ResizeObserver(() => flushSync(measure)); observer.observe(element); observer.observe(probe); if (composerOverlayElement) observer.observe(composerOverlayElement);