diff --git a/apps/web/e2e/a11y.spec.ts b/apps/web/e2e/a11y.spec.ts index 9f08551..92626bb 100644 --- a/apps/web/e2e/a11y.spec.ts +++ b/apps/web/e2e/a11y.spec.ts @@ -104,3 +104,55 @@ for (const scheme of SCHEMES) { }); }); } + +/** + * Reflow (WCAG 2.1 SC 1.4.10, issue #301): bei 320 px CSS-Breite — was 400 % + * Zoom auf 1280 px entspricht — darf die Seite nicht seitenweit horizontal + * scrollen. axe prüft das NICHT, das Kriterium ist nicht maschinell aus dem + * DOM ableitbar; deshalb ein eigener Zaun. + * + * Schlägt er an, nennt er die überstehenden Elemente. Ohne diese Diagnose + * weiß man nur DASS es überläuft und muss im Browser bisektieren. + */ +const NARROW = { width: 320, height: 800 }; + +async function expectNoHorizontalScroll(page: Page, label: string): Promise { + const report = await page.evaluate(() => { + const doc = document.documentElement; + const limit = doc.clientWidth; + const offenders: string[] = []; + for (const el of Array.from(document.querySelectorAll('body *'))) { + const rect = el.getBoundingClientRect(); + // 1 px Toleranz gegen Subpixel-Rundung. + if (rect.width > 0 && rect.right > limit + 1) { + const cls = + el.className && typeof el.className === 'string' + ? `.${el.className.trim().split(/\s+/).join('.')}` + : ''; + offenders.push( + `${el.tagName.toLowerCase()}${cls} (right=${Math.round(rect.right)}, width=${Math.round(rect.width)})`, + ); + } + } + return { scrollWidth: doc.scrollWidth, clientWidth: limit, offenders: offenders.slice(0, 12) }; + }); + expect( + { overflowBy: report.scrollWidth - report.clientWidth, offenders: report.offenders }, + `${label}: horizontaler Überlauf bei 320 px`, + ).toEqual({ overflowBy: 0, offenders: [] }); +} + +test.describe('reflow at 320px', () => { + test('user settings do not scroll horizontally at 320px', async ({ browser }) => { + const context = await contextForUser(browser, BASE, 'fixture-user'); + const page = await context.newPage(); + await page.setViewportSize(NARROW); + await page.goto('/settings'); + await page.waitForLoadState('networkidle'); + // Die Sitzungstabelle rendert asynchron und ist der breiteste Inhalt — + // ohne sie misst der Zaun eine halb aufgebaute Seite. + await page.locator('.table tbody tr').first().waitFor(); + await expectNoHorizontalScroll(page, '/settings'); + await context.close(); + }); +}); diff --git a/apps/web/src/pages/SettingsPage.tsx b/apps/web/src/pages/SettingsPage.tsx index 229ce07..67db9be 100644 --- a/apps/web/src/pages/SettingsPage.tsx +++ b/apps/web/src/pages/SettingsPage.tsx @@ -385,41 +385,56 @@ function SessionsSection(): React.JSX.Element { return (

{t('settings:sessions.title')}

- - - - - - - - - - - {(sessions.data ?? []).map((session) => ( - - - - - + {/* A table cannot shrink below its min-content width, so the user-agent + column pushed the whole page into horizontal scrolling at 320px + (issue #301, WCAG 1.4.10). It scrolls inside its own box instead — + the content stays reachable, which `overflow: hidden` would not. */} +
+
{t('settings:sessions.device')}{t('settings:sessions.created')}{t('settings:sessions.lastSeen')} - {t('common:tableActions')} -
- {session.userAgent ?? '—'} - {session.current && {t('settings:sessions.current')}} - {formatTime(session.createdAt)}{formatTime(session.lastSeenAt)} - {!session.current && ( - - )} -
+ + + + + + - ))} - -
{t('settings:sessions.device')}{t('settings:sessions.created')}{t('settings:sessions.lastSeen')} + {t('common:tableActions')} +
+ + + {(sessions.data ?? []).map((session) => ( + + + {session.userAgent ?? '—'} + {session.current && ( + {t('settings:sessions.current')} + )} + + {formatTime(session.createdAt)} + {formatTime(session.lastSeenAt)} + + {!session.current && ( + + )} + + + ))} + + + {others.length > 0 ? (