Skip to content

Commit

Permalink
fix(action-group): use the correct role for buttons when not selects
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook committed May 17, 2021
1 parent 7fe85e9 commit 0aae8ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/action-group/src/ActionGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export class ActionGroup extends SpectrumElement {
}
default:
this.buttons.forEach((option) => {
option.removeAttribute('role');
option.setAttribute('role', 'button');
option.tabIndex = 0;
});
this.removeAttribute('role');
Expand Down
11 changes: 11 additions & 0 deletions packages/action-group/test/action-group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ describe('ActionGroup', () => {
await elementUpdated(el);

await expect(el).to.be.accessible();
expect(el.getAttribute('aria-label')).to.equal('Default Group');
expect(el.hasAttribute('role')).to.be.false;
expect(el.children[0].getAttribute('role')).to.equal('button');
});
it('loads [selects="single"] action-group accessibly', async () => {
const el = await fixture<ActionGroup>(
Expand All @@ -77,6 +80,9 @@ describe('ActionGroup', () => {
await elementUpdated(el);

await expect(el).to.be.accessible();
expect(el.getAttribute('aria-label')).to.equal('Selects Single Group');
expect(el.getAttribute('role')).to.equal('radiogroup');
expect(el.children[0].getAttribute('role')).to.equal('radio');
});
it('loads [selects="single"] action-group w/ selection accessibly', async () => {
const el = await fixture<ActionGroup>(
Expand Down Expand Up @@ -110,6 +116,11 @@ describe('ActionGroup', () => {
await elementUpdated(el);

await expect(el).to.be.accessible();
expect(el.getAttribute('aria-label')).to.equal(
'Selects Multiple Group'
);
expect(el.getAttribute('role')).to.equal('group');
expect(el.children[0].getAttribute('role')).to.equal('checkbox');
});
it('loads [selects="multiple"] action-group w/ selection accessibly', async () => {
const el = await fixture<ActionGroup>(
Expand Down

0 comments on commit 0aae8ed

Please sign in to comment.