Skip to content

Commit 9dfc26b

Browse files
fix(ui): fit chat table cards to their columns (#122297)
* test(ui): cover chat table card width * fix(ui): fit chat table cards to columns
1 parent ff73a14 commit 9dfc26b

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

‎ui/src/pages/chat/chat-responsive.browser.test.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,6 +2055,47 @@ describeBrowserLayout.concurrent("chat responsive browser layout", () => {
20552055
},
20562056
);
20572057

2058+
it.each(["dark", "light"] as const)(
2059+
"fits short table cards to their columns in %s mode",
2060+
async (themeMode) => {
2061+
const page = await openBrowserPage(800, 400);
2062+
try {
2063+
await page.setContent(
2064+
`<!doctype html><html data-theme-mode="${themeMode}"><head><style>${readUiCss()}</style></head><body>
2065+
<div class="chat-text">
2066+
<div data-table-lane style="width: 680px">
2067+
<table data-short-table><thead><tr><th>Name</th><th>Status</th></tr></thead><tbody><tr><td>Gateway</td><td>Ready</td></tr></tbody></table>
2068+
</div>
2069+
<div data-narrow-table-lane style="width: 160px">
2070+
<table data-narrow-table><thead><tr><th>Name</th><th>Status</th></tr></thead><tbody><tr><td>Gateway</td><td>Ready</td></tr></tbody></table>
2071+
</div>
2072+
</div>
2073+
</body></html>`,
2074+
);
2075+
2076+
const geometry = await page.evaluate(() => {
2077+
const rectFor = (selector: string) =>
2078+
document.querySelector<HTMLElement>(selector)!.getBoundingClientRect();
2079+
const shortTable = rectFor("[data-short-table]");
2080+
const lastCell = rectFor("[data-short-table] tbody td:last-child");
2081+
return {
2082+
laneWidth: rectFor("[data-table-lane]").width,
2083+
narrowLaneWidth: rectFor("[data-narrow-table-lane]").width,
2084+
narrowTableWidth: rectFor("[data-narrow-table]").width,
2085+
shortTableWidth: shortTable.width,
2086+
trailingGap: shortTable.right - lastCell.right,
2087+
};
2088+
});
2089+
2090+
expect(geometry.shortTableWidth).toBeLessThan(geometry.laneWidth);
2091+
expect(geometry.trailingGap).toBeLessThanOrEqual(1);
2092+
expect(geometry.narrowTableWidth).toBeCloseTo(geometry.narrowLaneWidth, 0);
2093+
} finally {
2094+
await closeBrowserPage(page);
2095+
}
2096+
},
2097+
);
2098+
20582099
it.each(["dark", "light"] as const)(
20592100
"keeps mobile controls inside the viewport with touch targets in %s mode",
20602101
async (themeMode) => {

‎ui/src/styles/chat/text.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
border-radius: var(--radius-md);
7878
border-collapse: separate;
7979
border-spacing: 0;
80-
width: 100%;
80+
width: fit-content;
8181
max-width: 100%;
8282
background: color-mix(in srgb, var(--accent) 2%, var(--bg-elevated));
8383
box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 4%, transparent);

0 commit comments

Comments
 (0)