Skip to content
TypeScript

fix(web): chat content keeps pace with sidebar resizing (#17383)

olivera6698271a41a
diff --git a/apps/web/src/components/chat/ChatCanvas.tsx b/apps/web/src/components/chat/ChatCanvas.tsx
index 4df7ad66deb..c66e42f0607 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);