Skip to content

Commit 4ebb4df

Browse files
fix(web): measure the composer strip content width directly
1 parent 9afa7f5 commit 4ebb4df

4 files changed

Lines changed: 11 additions & 58 deletions

File tree

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ import { useComposerMenuProps } from "./chat/composerEventScope";
6868
import { measureRestingComposerControls } from "./chat/restingComposerControlsMeasurement";
6969
import { resolveRestingComposerControlsNaturalWidth } from "./composerFooterLayout";
7070
import { cn } from "~/lib/utils";
71-
import { contentInlineWidth } from "~/lib/contentInlineWidth";
7271
import { observeResize } from "~/lib/observeResize";
7372

7473
export interface BranchToolbarHandle {
@@ -427,11 +426,13 @@ function useLabelsOverflow(element: HTMLDivElement | null): boolean {
427426
const current = element;
428427
const compact = overflows;
429428
if (!current) return;
430-
if (current.clientWidth === 0) return;
431-
// Same free-space read the composer applies to the controls host, so the
432-
// labels never expand into room the docked controls already gave up.
429+
const stripWidth = current.clientWidth;
430+
if (stripWidth === 0) return;
433431
const stripStyle = getComputedStyle(current);
434-
const available = contentInlineWidth(current, stripStyle);
432+
const available =
433+
stripWidth -
434+
(Number.parseFloat(stripStyle.paddingInlineStart) || 0) -
435+
(Number.parseFloat(stripStyle.paddingInlineEnd) || 0);
435436
const contentWidth = (parent: Element): number => {
436437
const gap = Number.parseFloat(getComputedStyle(parent).columnGap) || 0;
437438
let width = 0;

‎apps/web/src/components/chat/ChatComposer.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ import {
217217
shouldUseRestingComposerLayout,
218218
} from "../composerFooterLayout";
219219
import { measureRestingComposerControls } from "./restingComposerControlsMeasurement";
220-
import { contentInlineWidth } from "~/lib/contentInlineWidth";
221220
import {
222221
type ComposerCitationCommentRequest,
223222
type ComposerPromptEditorHandle,
@@ -1159,7 +1158,11 @@ function useRestingComposerControlsLayout(host: HTMLDivElement | null, useContro
11591158

11601159
const measurement = measureRestingComposerControls(controls);
11611160
if (!measurement) return;
1162-
const hostWidth = contentInlineWidth(currentHost);
1161+
const style = getComputedStyle(currentHost);
1162+
const hostWidth =
1163+
currentHost.clientWidth -
1164+
(Number.parseFloat(style.paddingInlineStart) || 0) -
1165+
(Number.parseFloat(style.paddingInlineEnd) || 0);
11631166

11641167
setLayout((current) => {
11651168
const next = resolveRestingComposerControlsLayout({

‎apps/web/src/lib/contentInlineWidth.test.ts‎

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎apps/web/src/lib/contentInlineWidth.ts‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)