Skip to content

Commit 91bd7de

Browse files
committed
fix(a11y): remediate WCAG 2.2 AA failures across 9 elements
- validate: add aria-invalid on fields, aria-live on error messages - virtual-list: add role=listbox/option, keyboard nav (Arrow/Home/End) - dnd: replace deprecated aria-grabbed with aria-roledescription, add live-region screen reader announcements, role=button on draggables - table sort: add tabindex=0 and Enter/Space keyboard activation - table reorder: replace aria-grabbed with aria-roledescription - accordion: add aria-expanded, aria-controls, role=region on panels - popover: add role=dialog (respecting existing roles), aria-haspopup=dialog - toast/stepper: already WCAG-compliant, no changes needed - Update tests to match new ARIA attributes
1 parent e12ca79 commit 91bd7de

15 files changed

Lines changed: 146 additions & 73 deletions

__tests__/dnd.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ describe('Drag Directive', () => {
315315
el.dispatchEvent(new Event('dragend', { bubbles: true }));
316316
expect(el.classList.contains('nojs-dragging')).toBe(false);
317317
expect(el.getAttribute('aria-grabbed')).toBeNull();
318+
expect(el.getAttribute('aria-roledescription')).toBe('draggable item');
318319
});
319320

320321
test('26 - dragend dispatches drag-end custom event', () => {
@@ -346,6 +347,7 @@ describe('Drag Directive', () => {
346347

347348
expect(_dndState.dragging).toBeTruthy();
348349
expect(el.getAttribute('aria-grabbed')).toBeNull();
350+
expect(el.getAttribute('aria-roledescription')).toBe('draggable item');
349351
expect(el.classList.contains('nojs-dragging')).toBe(true);
350352
});
351353

@@ -357,6 +359,7 @@ describe('Drag Directive', () => {
357359
el.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
358360
expect(_dndState.dragging).toBeNull();
359361
expect(el.getAttribute('aria-grabbed')).toBeNull();
362+
expect(el.getAttribute('aria-roledescription')).toBe('draggable item');
360363
expect(el.classList.contains('nojs-dragging')).toBe(false);
361364
});
362365
});

__tests__/integrations.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ describe('Table + DnD: table-reorder directive', () => {
6464
expect(rows[2].draggable).toBe(true);
6565
});
6666

67-
test('2 - rows have aria-grabbed=false initially', () => {
67+
test('2 - rows have aria-roledescription initially', () => {
6868
const { tbody } = setupReorderTable();
6969
const rows = tbody.querySelectorAll('tr');
7070
for (const row of rows) {
71-
expect(row.getAttribute('aria-grabbed')).toBe('false');
71+
expect(row.getAttribute('aria-roledescription')).toBe('draggable row');
7272
}
7373
});
7474

@@ -94,7 +94,7 @@ describe('Table + DnD: table-reorder directive', () => {
9494
row.dispatchEvent(evt);
9595

9696
expect(row.classList.contains('nojs-row-dragging')).toBe(true);
97-
expect(row.getAttribute('aria-grabbed')).toBe('true');
97+
expect(row.getAttribute('aria-roledescription')).toBe('draggable row');
9898
});
9999

100100
test('5 - custom drag class is used', () => {
@@ -119,7 +119,7 @@ describe('Table + DnD: table-reorder directive', () => {
119119

120120
row.dispatchEvent(new Event('dragend', { bubbles: true }));
121121
expect(row.classList.contains('nojs-row-dragging')).toBe(false);
122-
expect(row.getAttribute('aria-grabbed')).toBe('false');
122+
expect(row.getAttribute('aria-roledescription')).toBe('draggable row');
123123
});
124124

125125
test('7 - dispatches table:reorder event on drop', () => {

__tests__/tooltip.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ describe('Popover Directive', () => {
224224

225225
test('13 - popover trigger has correct ARIA attributes', () => {
226226
const { triggerEl } = setupPopover('my-popover');
227-
expect(triggerEl.getAttribute('aria-haspopup')).toBe('true');
227+
expect(triggerEl.getAttribute('aria-haspopup')).toBe('dialog');
228228
expect(triggerEl.getAttribute('aria-expanded')).toBe('false');
229229
expect(triggerEl.getAttribute('aria-controls')).toBe('my-popover');
230230
});

dist/cjs/nojs-elements.js

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cjs/nojs-elements.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/nojs-elements.js

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/nojs-elements.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iife/nojs-elements.js

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iife/nojs-elements.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/popover/popover.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export function registerPopoverDirective(NoJS) {
129129

130130
// Set native popover attribute for Popover API
131131
el.setAttribute("popover", "auto");
132+
if (!el.getAttribute("role")) el.setAttribute("role", "dialog");
132133
el.classList.add("nojs-popover");
133134

134135
const position = el.getAttribute("popover-position") || "bottom";
@@ -198,7 +199,7 @@ export function registerPopoverDirective(NoJS) {
198199
}
199200
}
200201

201-
el.setAttribute("aria-haspopup", "true");
202+
el.setAttribute("aria-haspopup", "dialog");
202203
el.setAttribute("aria-expanded", "false");
203204
el.setAttribute("aria-controls", popoverId);
204205

0 commit comments

Comments
 (0)