Skip to content

Commit d26277c

Browse files
matt2eclaude
andcommitted
fix(desktop): keep FileCard inside narrow message rows
A non-image attachment card overflowed its message row in the thread side pane: the card ran past the row's right edge and its download icon was clipped off entirely. FileCard is an `inline-flex` box, which is shrink-to-fit, so its width floors at its own min-content size. That min-content width is set by the `truncate` (white-space: nowrap) filename, and the child's `overflow: hidden` only relaxes the flex item's automatic minimum, not the container's intrinsic min-content. With only `max-w-sm` (24rem) as a cap, a long filename grew the card to the cap regardless of how narrow the pane was (~300px body in the default 380px thread pane). Add `max-w-full` so the cap becomes min(24rem, 100%). The ancestors already carry `min-w-0` on the flex column, so the percentage resolves against the pane width and the card shrinks, the filename ellipsises, and the size and download icon stay visible. Other FileCard surfaces (forum posts, DMs, wide timelines) are unaffected since 100% exceeds 24rem there. Add a Playwright regression test that seeds a long-named text attachment, opens its thread, and asserts the card and its trailing icon stay within the row while the filename is actually truncated. Without the fix the card's right edge lands ~82px past the row. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Matt Toohey <[email protected]>
1 parent a38fedb commit d26277c

2 files changed

Lines changed: 98 additions & 1 deletion

File tree

‎desktop/src/shared/ui/markdown/FileCard.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function FileCard({
5555
);
5656
}}
5757
data-testid="file-card"
58-
className="my-1 inline-flex max-w-sm items-center gap-3 rounded-2xl border border-border/70 bg-muted/40 px-3 py-2 text-left no-underline transition-colors hover:bg-muted/70"
58+
className="my-1 inline-flex max-w-full items-center gap-3 rounded-2xl border border-border/70 bg-muted/40 px-3 py-2 text-left no-underline transition-colors hover:bg-muted/70"
5959
style={{ borderRadius: "1rem" }}
6060
>
6161
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-background text-muted-foreground">

‎desktop/tests/e2e/file-attachment.spec.ts‎

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,3 +725,100 @@ test("a non-media attachment's remove button is named and keyboard-operable", as
725725
await page.keyboard.press("Enter");
726726
await expect(composer).not.toContainText("quarterly-report.pdf");
727727
});
728+
729+
test("a long filename stays inside the narrow thread pane row", async ({
730+
page,
731+
}) => {
732+
// Regression: FileCard is an inline-flex (shrink-to-fit) box whose
733+
// min-content width is set by its `truncate` (nowrap) filename. With only a
734+
// 24rem cap it grew past a ~300px thread-pane row and clipped the download
735+
// icon; `max-w-full` makes the cap min(24rem, 100%) so the card shrinks and
736+
// the filename ellipsises instead.
737+
const filename =
738+
"Running onboarding-flow first run with a temporary identity and wiped communities.txt";
739+
const sha256 = "b".repeat(64);
740+
const url = `https://mock.relay/media/${sha256}.txt`;
741+
742+
await page.goto("/");
743+
await page.waitForFunction(
744+
() =>
745+
typeof (window as Window & { __BUZZ_E2E_INVOKE_MOCK_COMMAND__?: unknown })
746+
.__BUZZ_E2E_INVOKE_MOCK_COMMAND__ === "function",
747+
null,
748+
{ timeout: 5_000 },
749+
);
750+
await page.evaluate(
751+
async ({ content, mediaTags }) => {
752+
const invoke = (
753+
window as Window & {
754+
__BUZZ_E2E_INVOKE_MOCK_COMMAND__: (
755+
command: string,
756+
payload: Record<string, unknown>,
757+
) => Promise<unknown>;
758+
}
759+
).__BUZZ_E2E_INVOKE_MOCK_COMMAND__;
760+
await invoke("send_channel_message", {
761+
channelId: "9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50",
762+
content,
763+
mediaTags,
764+
});
765+
},
766+
{
767+
content: `[${filename}](${url})`,
768+
mediaTags: [
769+
[
770+
"imeta",
771+
`url ${url}`,
772+
"m text/plain",
773+
`x ${sha256}`,
774+
"size 13312",
775+
`filename ${filename}`,
776+
],
777+
],
778+
},
779+
);
780+
781+
await page.getByTestId("channel-general").click();
782+
const timelineRow = page
783+
.getByTestId("message-timeline")
784+
.getByTestId("message-row")
785+
.filter({ has: page.getByTestId("file-card") })
786+
.last();
787+
await expect(timelineRow).toBeVisible();
788+
await timelineRow.hover();
789+
await timelineRow.getByRole("button", { name: "Reply" }).click();
790+
791+
// The thread head renders the same message in the default 380px pane.
792+
const threadRow = page
793+
.getByTestId("message-thread-panel")
794+
.getByTestId("message-thread-head")
795+
.getByTestId("message-row");
796+
const card = threadRow.getByTestId("file-card");
797+
await expect(card).toBeVisible();
798+
await expect(card).toContainText("13 KB");
799+
800+
const [rowBox, cardBox, iconBox] = await Promise.all([
801+
threadRow.boundingBox(),
802+
card.boundingBox(),
803+
card.locator("svg").last().boundingBox(),
804+
]);
805+
if (!rowBox || !cardBox || !iconBox) {
806+
throw new Error("Expected the thread row, card, and icon to lay out.");
807+
}
808+
// The pane is narrower than the card's 24rem cap, so the filename must be
809+
// ellipsised — otherwise this test would not be exercising the overflow.
810+
expect(rowBox.width).toBeLessThan(384);
811+
await expect
812+
.poll(() =>
813+
card
814+
.getByText(filename)
815+
.evaluate((el) => el.scrollWidth > el.clientWidth),
816+
)
817+
.toBe(true);
818+
expect(cardBox.x + cardBox.width).toBeLessThanOrEqual(
819+
rowBox.x + rowBox.width + 0.5,
820+
);
821+
expect(iconBox.x + iconBox.width).toBeLessThanOrEqual(
822+
rowBox.x + rowBox.width + 0.5,
823+
);
824+
});

0 commit comments

Comments
 (0)