Skip to content

Commit

Permalink
fix(button-toggle): set aria-disabled based on group disabled state (#…
Browse files Browse the repository at this point in the history
…12828)

Based on the [ARIA spec](https://www.w3.org/TR/wai-aria-1.1/#group) elements with a `group` role can have `aria-disabled`. These changes set the attribute, based on whether the group is disabled.
  • Loading branch information
crisbeto authored and jelbourn committed Aug 27, 2018
1 parent e18a99f commit 5969523
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/lib/button-toggle/button-toggle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@ describe('MatButtonToggle without forms', () => {
expect(buttonToggleInstances[0].checked).toBe(true);
});

it('should set aria-disabled based on whether the group is disabled', () => {
expect(groupNativeElement.getAttribute('aria-disabled')).toBe('false');

testComponent.isGroupDisabled = true;
fixture.detectChanges();

expect(groupNativeElement.getAttribute('aria-disabled')).toBe('true');
});

it('should update the group value when one of the toggles changes', () => {
expect(groupInstance.value).toBeFalsy();
buttonToggleLabelElements[0].click();
Expand Down
3 changes: 2 additions & 1 deletion src/lib/button-toggle/button-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class MatButtonToggleChange {
host: {
'role': 'group',
'class': 'mat-button-toggle-group',
'[attr.aria-disabled]': 'disabled',
'[class.mat-button-toggle-vertical]': 'vertical'
},
exportAs: 'matButtonToggleGroup',
Expand All @@ -98,7 +99,7 @@ export class MatButtonToggleGroup extends _MatButtonToggleGroupMixinBase impleme

/**
* Reference to the raw value that the consumer tried to assign. The real
* value will exaclude any values from this one that don't correspond to a
* value will exclude any values from this one that don't correspond to a
* toggle. Useful for the cases where the value is assigned before the toggles
* have been initialized or at the same that they're being swapped out.
*/
Expand Down

0 comments on commit 5969523

Please sign in to comment.