Skip to content

Commit bed5d07

Browse files
committed
fix(web): composer context strip no longer counts its padding as free space
1 parent e55e731 commit bed5d07

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎apps/web/src/components/BranchToolbar.tsx‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,15 @@ function useLabelsOverflow(element: HTMLDivElement | null): boolean {
361361
const measure = useCallback(() => {
362362
const { element: current, overflows: compact } = stateRef.current;
363363
if (!current) return;
364-
const available = current.clientWidth;
365-
if (available === 0) return;
364+
if (current.clientWidth === 0) return;
365+
// The strip's own padding is not room for its children. Counting it let
366+
// labels expand while the composer controls hosted here had already
367+
// collapsed to icons for lack of space.
368+
const stripStyle = getComputedStyle(current);
369+
const available =
370+
current.clientWidth -
371+
(Number.parseFloat(stripStyle.paddingInlineStart) || 0) -
372+
(Number.parseFloat(stripStyle.paddingInlineEnd) || 0);
366373
// flex-1 stretches the groups to fill the strip, so their own boxes always
367374
// measure "full". Sum the laid-out content instead, skipping hidden form
368375
// artifacts and other out-of-flow nodes.
@@ -384,7 +391,7 @@ function useLabelsOverflow(element: HTMLDivElement | null): boolean {
384391
}
385392
return width + gap * Math.max(0, counted - 1);
386393
};
387-
const stripGap = Number.parseFloat(getComputedStyle(current).columnGap) || 0;
394+
const stripGap = Number.parseFloat(stripStyle.columnGap) || 0;
388395
let needed = 0;
389396
let groups = 0;
390397
for (const child of current.children) {

0 commit comments

Comments
 (0)