diff --git a/apps/app/e2e/shell/editor-more-menu.spec.ts b/apps/app/e2e/shell/editor-more-menu.spec.ts index 41b82586..dcca48f6 100644 --- a/apps/app/e2e/shell/editor-more-menu.spec.ts +++ b/apps/app/e2e/shell/editor-more-menu.spec.ts @@ -111,6 +111,11 @@ test.describe('« Plus » dropdown', () => { const boxes = await rows.evaluateAll((els) => els.map((el) => el.getBoundingClientRect().toJSON()), ) + expect(new Set(boxes.map((b) => Math.round(b.x))).size, 'same x').toBe(1) + expect( + new Set(boxes.map((b) => Math.round(b.width))).size, + 'same width', + ).toBe(1) boxes.forEach((box, at) => { expect(box.height, `row ${at} height`).toBeGreaterThanOrEqual(44) expect(box.x, `row ${at} left`).toBeGreaterThanOrEqual(0) @@ -122,6 +127,13 @@ test.describe('« Plus » dropdown', () => { } }) await expectAccessible(page, `« Plus » list at ${width} px`) + // An active row: pick Constats, reopen, axe with the tint and the check. + await rows.first().click() + await more(page).click() + await expect(list(page).locator('[aria-current="true"]')).toHaveCount(1) + // Axe reads the colours: wait until the fade-in has ended. + await expect(list(page)).toHaveCSS('opacity', '1') + await expectAccessible(page, `« Plus » list, active row, at ${width} px`) }) } diff --git a/apps/app/src/components/editor/EditorTabs.tsx b/apps/app/src/components/editor/EditorTabs.tsx index eb4d2096..cfe5d543 100644 --- a/apps/app/src/components/editor/EditorTabs.tsx +++ b/apps/app/src/components/editor/EditorTabs.tsx @@ -20,17 +20,27 @@ import { useT } from '@/i18n/useT' import HistoryButtons from './HistoryButtons' import { MORE_LIST_ID, useMoreDismiss, useMoreMenu } from './useMoreMenu' -const BASE = - 'min-h-11 whitespace-nowrap border-b-2 px-3 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]' +const FOCUS_RING = + 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]' +const BASE = `min-h-11 whitespace-nowrap border-b-2 px-3 text-sm ${FOCUS_RING}` const ACTIVE = 'border-[var(--color-accent)] font-medium text-[var(--color-accent-strong)]' const IDLE = 'border-transparent text-[var(--color-ink-muted)] hover:text-[var(--color-ink)]' const ROW = - 'flex min-h-12 w-full items-center justify-between gap-3 rounded-md px-4 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]' + `flex min-h-12 w-full items-center justify-between gap-3 rounded-md px-4 text-left + text-sm ${FOCUS_RING}`.replace(/\s+/g, ' ') const ROW_ACTIVE = 'bg-[var(--color-accent)]/10 font-medium text-[var(--color-accent-strong)]' +const ROW_IDLE = + 'text-[var(--color-ink-muted)] hover:bg-[var(--color-accent)]/5 hover:text-[var(--color-ink)]' +const MORE_PANEL = + `absolute inset-x-0 top-full z-20 mt-1 flex flex-col gap-1 rounded-lg border + border-[var(--color-border)] bg-[var(--color-surface)] p-2 shadow-lg`.replace( + /\s+/g, + ' ', + ) /** The blocking-error count on the Vérification tab, as text; absent at zero. */ function ErrorCount({ tab }: { tab: EditorTabId }) { @@ -138,7 +148,7 @@ function MoreList({ more, active, onPick }: MoreListProps) { transition: { duration: reduced ? 0 : 0.15 }, }} exit={{ ...hidden, transition: { duration: reduced ? 0 : 0.12 } }} - className="absolute inset-x-0 top-full z-20 mt-1 flex flex-col gap-1 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-2 shadow-lg" + className={MORE_PANEL} > {more.map((tab) => (
  • @@ -147,7 +157,7 @@ function MoreList({ more, active, onPick }: MoreListProps) { type="button" aria-current={tab === active ? 'true' : undefined} onClick={() => onPick(tab)} - className={`${ROW} ${tab === active ? ROW_ACTIVE : IDLE}`} + className={`${ROW} ${tab === active ? ROW_ACTIVE : ROW_IDLE}`} > {t(`editor.tab.${tab}`)} diff --git a/apps/app/tests/unit/editor-more-menu.test.tsx b/apps/app/tests/unit/editor-more-menu.test.tsx index 78824f5f..2dfc3ad5 100644 --- a/apps/app/tests/unit/editor-more-menu.test.tsx +++ b/apps/app/tests/unit/editor-more-menu.test.tsx @@ -65,7 +65,7 @@ function mount() { } describe('the overlay', () => { - it('opens as an absolute full-width overlay under the row and closes on a second click', async () => { + it('opens as a full-width overlay under the row, a second click closes', async () => { const { user } = mount() await user.click(more()) expect(more()).toHaveAttribute('aria-expanded', 'true') @@ -110,6 +110,7 @@ describe('the vertical list', () => { ]) expect(list()!.querySelector('[aria-current]')).toBeNull() rows.forEach((row) => expect(row).toHaveClass('min-h-12', 'w-full')) + rows.forEach((row) => expect(row.className).toContain('hover:bg-')) await user.click(rows[0]) await user.click(more()) const current = list()!.querySelectorAll('[aria-current="true"]') @@ -305,7 +306,7 @@ describe('final review: keyboard focus leaving « Plus » (M-8)', () => { await gone() }) - it('a focus placed elsewhere by the page keeps it open: Escape closes it and returns the focus', async () => { + it('a focus placed elsewhere keeps it open: Escape closes and returns the focus', async () => { const { user } = mount() await user.click(more()) act(() => screen.getByRole('button', { name: 'outside' }).focus())