fix(ui): wrap truncated drawer values on phones instead of tap-only tooltips

TextTooltip only reveals its full text on an ancestor's :focus-visible,
which a tap never produces, so a truncated value in a detail drawer (the
connection detail's rule expression, for one) had no way to be read in
full on a phone. The drawer already scrolls vertically, so on phones let
a truncated value wrap instead of truncating; desktop keeps the
single-line truncation and its tooltip.

Not done: the same problem in table cells (for example the Events log)
would need a new interaction model, since TextTooltip's reveal is tied
to keyboard focus and a table row's own press handling; that is left for
the owner to decide on.
This commit is contained in:
Zakk committed 2026-09-26 12:28:23 +10:00
1 parent 9771249a8e
commit 680c47db20
2 files changed
+35

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import {detail, expect, mockBackend, test} from './fixtures';
// TextTooltip only reveals on an ancestor's :focus-visible, which a tap never produces (src/ui/Button.tsx). On a
// phone the detail drawer has vertical room to spare, so a value that would otherwise truncate wraps instead, and the
// full text is on screen without needing the tooltip at all.
test('a truncated rule expression in the detail drawer wraps on phones instead of relying on a tap-only tooltip', async ({page}) => {
const {api} = await mockBackend(page);
const connections = await api.connections();
const row = connections.tcp.find(row => row.rule_expression && row.chain.length)!;
await page.setViewportSize({width: 390, height: 844});
await page.goto(`/#/connections?id=${encodeURIComponent(row.id)}`);
const rule = detail(page).locator('.rp-list .rp-truncate').first();
await expect(rule).toHaveText(row.rule_expression!);
expect(await rule.evaluate(el => getComputedStyle(el).whiteSpace)).toBe('normal');
});
test('the same value stays a single-line truncation with its tooltip on desktop', async ({page}) => {
const {api} = await mockBackend(page);
const connections = await api.connections();
const row = connections.tcp.find(row => row.rule_expression && row.chain.length)!;
await page.setViewportSize({width: 1280, height: 900});
await page.goto(`/#/connections?id=${encodeURIComponent(row.id)}`);
const rule = detail(page).locator('.rp-list .rp-truncate').first();
await expect(rule).toHaveText(row.rule_expression!);
expect(await rule.evaluate(el => getComputedStyle(el).whiteSpace)).toBe('nowrap');
});
+9
View File
@@ -34,6 +34,15 @@
white-space: nowrap;
vertical-align: middle;
}
/* A drawer scrolls vertically already, so on phones a truncated value wraps to show it whole instead of relying on
TextTooltip's reveal, which needs :focus-visible and so never opens on a tap. */
@media (max-width: 599.98px) {
.rp-drawer .rp-truncate {
white-space: normal;
overflow: visible;
text-overflow: clip;
}
}
/* A badge truncates like any label but keeps its flex box, which is what centres its text. */
.rp-truncate.rp-badge {
display: inline-flex;