From 680c47db20cecd83362cc93ebb7a4abcff7a5a2f Mon Sep 17 00:00:00 2001 From: Zakk Date: Sat, 26 Sep 2026 12:12:16 +1000 Subject: [PATCH] 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. --- e2e/phone-connections-drawer.spec.ts | 26 ++++++++++++++++++++++++++ src/ui/styles/interaction-states.css | 9 +++++++++ 2 files changed, 35 insertions(+) create mode 100644 e2e/phone-connections-drawer.spec.ts diff --git a/e2e/phone-connections-drawer.spec.ts b/e2e/phone-connections-drawer.spec.ts new file mode 100644 index 00000000..4b7db759 --- /dev/null +++ b/e2e/phone-connections-drawer.spec.ts @@ -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'); +}); diff --git a/src/ui/styles/interaction-states.css b/src/ui/styles/interaction-states.css index 37eecb36..c66f8ffd 100644 --- a/src/ui/styles/interaction-states.css +++ b/src/ui/styles/interaction-states.css @@ -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;