Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(ui): correct the resize listener target in toolbar (#2321)

白熱734c4d20a48a
diff --git a/packages/ui/src/views/components/doc-bars/hook.ts b/packages/ui/src/views/components/doc-bars/hook.ts
index d2656c2c90..44184a3c80 100644
--- a/packages/ui/src/views/components/doc-bars/hook.ts
+++ b/packages/ui/src/views/components/doc-bars/hook.ts
@@ -181,8 +181,13 @@ export function useToolbarCollapseObserver(visibleItems: IToolbarRenderHookHandl
resize();
const observer = new ResizeObserver(() => resize());
- observer.observe(document.body);
- return () => observer.unobserve(document.body);
+
+ const toolbarDom = toolbarRef.current!;
+ observer.observe(toolbarDom);
+
+ return () => {
+ observer.unobserve(toolbarDom);
+ };
}, [visibleItems]);
return {