Skip to content

Commit c99ad4a

Browse files
authored
test(DropdownMenu): radio-item and sub-menu audits expect a disabled row in the roving order (#10622)
* test(DropdownMenu): the radio-item and sub-menu audits expect a disabled row in the roving order A disabled row now keeps tabindex=-1 so the arrow keys reach it, and it stays inert. Two component audits still expected no tabindex on the disabled row, so they failed in every theme and state. * test(DropdownMenu): the radio-item and sub-menu audits press the disabled row and check it stays inert A click, Enter and Space on the disabled radio row neither check it nor reach the consumer's handler. A click, Enter, Space and the open key on the disabled sub-menu trigger open no flyout and pick nothing. * test(DropdownMenu): the sub-menu audit checks the disabled trigger stays collapsed * Merge branch 'main' into fix/menu-audits-disabled-row-tabindex * Merge branch 'main' into fix/menu-audits-disabled-row-tabindex
1 parent 7e82663 commit c99ad4a

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

‎packages/core/src/DropdownMenu/__tests__/DropdownMenuRadioItemAudit.a11y.chromium.spec.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,18 @@ for (const item of cases) {
216216
await row('List').click();
217217
await expect(row('List')).toHaveAttribute('aria-checked', 'true');
218218
} else if (item.interaction === 'disabled-hover') {
219+
// The disabled row is inert: a click, Enter and Space neither check it
220+
// nor reach the consumer's handler (the `checked` and
221+
// `consumerHandlers` checks). ArrowUp then moves focus off it.
222+
const box = await row('Archive').boundingBox();
223+
if (box == null) {
224+
throw new Error('the disabled row has no box');
225+
}
226+
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
227+
await row('Archive').focus();
228+
await page.keyboard.press('Enter');
229+
await page.keyboard.press(' ');
230+
await page.keyboard.press('ArrowUp');
219231
await row('Archive').hover();
220232
}
221233
await settle(page);
@@ -458,9 +470,10 @@ for (const item of cases) {
458470
rows: observed.rows.length === 5,
459471
checked:
460472
checked.length === 1 && checked[0].startsWith(expectedChecked(item)),
473+
// A disabled row stays in the roving order, so the arrow keys reach it.
461474
disabledRow:
462475
observed.rows[4]?.disabled === 'true' &&
463-
observed.rows[4]?.tabIndex === null,
476+
observed.rows[4]?.tabIndex === '-1',
464477
activeRow:
465478
active === undefined
466479
? true

‎packages/core/src/DropdownMenu/__tests__/DropdownMenuSubMenuAudit.a11y.chromium.spec.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,20 @@ for (const item of cases) {
279279
await expect(flyout).toBeVisible();
280280
await page.mouse.down();
281281
} else if (item.interaction === 'disabled-hover') {
282-
await row(menu, 'Archive').hover();
282+
// The disabled trigger is inert: a click, Enter, Space and the open key
283+
// leave it collapsed (the `rowStates` check) and pick nothing (the
284+
// `counters` check).
285+
const archive = row(menu, 'Archive');
286+
const box = await archive.boundingBox();
287+
if (box == null) {
288+
throw new Error('the disabled row has no box');
289+
}
290+
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
291+
await archive.focus();
292+
await page.keyboard.press('Enter');
293+
await page.keyboard.press(' ');
294+
await page.keyboard.press(openKey);
295+
await archive.hover();
283296
await page.waitForTimeout(600);
284297
} else if (item.interaction === 'drill-in') {
285298
await subject.click();
@@ -607,7 +620,8 @@ for (const item of cases) {
607620
item.interaction === 'select' ||
608621
item.interaction === 'drill-in' ||
609622
(findRow('Archive')?.disabled === 'true' &&
610-
findRow('Archive')?.tabIndex === null &&
623+
findRow('Archive')?.tabIndex === '-1' &&
624+
findRow('Archive')?.expanded === 'false' &&
611625
findRow('Export')?.spinnerHidden === true &&
612626
findRow('Share')?.haspopup === 'menu'),
613627
indicatorMirror:

0 commit comments

Comments
 (0)