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.

feat(toolbar): add automatic calculation of toolbar gap style (#2345)

小马同学91f3b7cdc492
diff --git a/packages/ui/src/views/components/doc-bars/hook.ts b/packages/ui/src/views/components/doc-bars/hook.ts
index 44184a3c80..d98e4f1b77 100644
--- a/packages/ui/src/views/components/doc-bars/hook.ts
+++ b/packages/ui/src/views/components/doc-bars/hook.ts
@@ -157,7 +157,13 @@ export function useToolbarCollapseObserver(visibleItems: IToolbarRenderHookHandl
useEffect(() => {
function resize() {
const wrapperWidth = toolbarRef.current?.clientWidth ?? 0;
- const GAP = 8;
+ let GAP = 0;
+ if (toolbarRef.current) {
+ // firstElementChild is toolbar container
+ const gapValue = Number.parseInt(getComputedStyle(toolbarRef.current.firstElementChild!).gap, 10);
+ GAP = Number.isNaN(gapValue) ? 0 : gapValue;
+ }
+
const itemWidths = Object.entries(toolbarItemRefs.current)
.filter(([_, ref]) => ref.el && ref.key && visibleItems.find((item) => item.id === ref.key))
.map(([_, ref]) => ({