feat(editor): dialog close button is a 44 px touch box

This commit is contained in:
bchanot committed 2026-11-15 19:40:46 +01:00
1 parent ae02f48853
commit 240c2ba0e7
4 files changed
+79 -5

No files matched your search

+10 -1
View File
@@ -17,7 +17,11 @@ const lang: Locale =
useLocaleStore.setState({ locale: lang })
document.documentElement.lang = lang
type Scenario = 'basic' | 'long' | 'guarded' | 'vanishing' | null
/** Wraps on a phone: the close button must keep its 44 px box beside it. */
const LONG_TITLE =
'A dialog title long enough to wrap over several lines on a narrow phone screen'
type Scenario = 'basic' | 'long' | 'title' | 'guarded' | 'vanishing' | null
function Background({ onOpen }: { onOpen: (scenario: Scenario) => void }) {
const [clicks, setClicks] = useState(0)
@@ -26,6 +30,7 @@ function Background({ onOpen }: { onOpen: (scenario: Scenario) => void }) {
<div className="flex flex-wrap gap-2">
<Button onClick={() => onOpen('basic')}>Open basic</Button>
<Button onClick={() => onOpen('long')}>Open long</Button>
<Button onClick={() => onOpen('title')}>Open wrapped title</Button>
<Button onClick={() => onOpen('guarded')}>Open guarded</Button>
</div>
<Button variant="secondary" onClick={() => setClicks((n) => n + 1)}>
@@ -88,6 +93,10 @@ function Harness() {
<Button onClick={close}>End of content</Button>
</Dialog>
<Dialog open={scenario === 'title'} onClose={close} title={LONG_TITLE}>
<Button onClick={close}>Done</Button>
</Dialog>
<Dialog
open={scenario === 'guarded'}
onClose={() => !busy && close()}
+25
View File
@@ -198,6 +198,31 @@ test('fits the viewport without horizontal page scroll', async ({ page }) => {
}
})
// Rev 6: the ✕ is a 44 × 44 px touch box (MobileDrawer's), never squeezed by a long title.
test('the close button is a 44 px box beside a long title at 320, 375 and 1280 px', async ({
page,
}) => {
const title =
'A dialog title long enough to wrap over several lines on a narrow phone screen'
const dialog = await openScenario(page, 'Open wrapped title', title)
const close = dialog.getByRole('button', { name: fr['common.close'] })
for (const width of [320, 375, 1280]) {
await page.setViewportSize({ width, height: 700 })
// Polled: the panel scales in (0.96 to 1) right after it opens.
const box = async () => (await close.boundingBox())!
await expect
.poll(async () => (await box()).width, { message: `✕ width at ${width}` })
.toBeGreaterThanOrEqual(44)
expect((await box()).height, `✕ height at ${width}`).toBeGreaterThanOrEqual(
44,
)
const { x, width: size } = await box()
expect(x + size, `✕ inside at ${width}`).toBeLessThanOrEqual(width + 0.5)
await expectNoHorizontalOverflow(page, `the long title at ${width}`)
}
await expectAccessible(page, 'the long-title dialog')
})
for (const [lang, dict] of [
['fr', fr],
['en', en],