Skip to content

Commit

Permalink
fix(selectable box): screen-reader accessibility when box is clickable (
Browse files Browse the repository at this point in the history
VIV-000) (#1907)

* fix: selectable-box announced as a toggle btn when clickable

* chore: formatting

---------

Co-authored-by: James Taylor <jstaylor@vonht2fg32k90.home>
  • Loading branch information
TaylorJ76 and James Taylor authored Sep 17, 2024
1 parent 40b8a95 commit 512cc7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions libs/components/src/lib/selectable-box/selectable-box.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ describe('vwc-selectable-box', () => {

expect(control?.getAttribute('tabindex')).toBe(null);
expect(control?.getAttribute('aria-label')).toBe('Box 1');
expect(control?.getAttribute('aria-press')).toBe(null);
});

describe('radio', () => {
Expand Down Expand Up @@ -473,7 +474,7 @@ describe('vwc-selectable-box', () => {

it('should put the correct a11y attributes on the base element', async () => {
expect(baseElement?.getAttribute('aria-label')).toBe('Box 1');
expect(baseElement?.getAttribute('aria-pressed')).toBe(null);
expect(baseElement?.getAttribute('aria-pressed')).toBe('false');
expect(baseElement?.getAttribute('role')).toBe('button');
expect(baseElement?.getAttribute('tabindex')).toBe('0');
});
Expand Down Expand Up @@ -518,7 +519,7 @@ describe('vwc-selectable-box', () => {

it('should put the correct a11y attributes on the base element', async () => {
expect(baseElement?.getAttribute('aria-label')).toBe('Box 1');
expect(baseElement?.getAttribute('aria-pressed')).toBe(null);
expect(baseElement?.getAttribute('aria-pressed')).toBe('false');
expect(baseElement?.getAttribute('role')).toBe('button');
expect(baseElement?.getAttribute('tabindex')).toBe('0');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const SelectableBoxTemplate: (
tabindex="${(x) => (x.clickableBox || x.clickable ? '0' : null)}"
role="${(x) => (x.clickableBox || x.clickable ? 'button' : null)}"
aria-pressed="${(x) =>
(x.clickableBox || x.clickable) && x.checked ? x.checked : null}"
x.clickableBox || x.clickable ? (x.checked ? 'true' : 'false') : null}"
aria-label="${(x) =>
x.clickableBox || x.clickable ? x.ariaLabel : null}"
@keydown="${(x, c) => x._handleKeydown(c.event as KeyboardEvent)}"
Expand Down

0 comments on commit 512cc7c

Please sign in to comment.