Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(button-toggle): set aria-disabled based on group disabled state #12828

Merged
merged 1 commit into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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