fix(editor): Plus rows hover tint, axe on an active row, line limits
This commit is contained in:
1 parent
2c4c771269
commit
da755f9768
3 files changed
+30
-7
No files matched your search
@@ -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`)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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) => (
|
||||
<li key={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}`}
|
||||
>
|
||||
<span>
|
||||
{t(`editor.tab.${tab}`)}
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in new issue
Block a user