Skip to content

Commit 83acefe

Browse files
committed
fix(material/button-toggle): fix ChromeVox focus issue on button toggle
1 parent 94bd0d4 commit 83acefe

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/material/button-toggle/button-toggle.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,13 +800,13 @@ describe('MatButtonToggle without forms', () => {
800800
expect(button.getAttribute('tabindex')).toBe('3');
801801
});
802802

803-
it('should clear the tabindex from the host element', () => {
803+
it('should have role "presentation"', () => {
804804
const fixture = TestBed.createComponent(ButtonToggleWithTabindex);
805805
fixture.detectChanges();
806806

807807
const host = fixture.nativeElement.querySelector('.mat-button-toggle');
808808

809-
expect(host.getAttribute('tabindex')).toBe('-1');
809+
expect(host.getAttribute('role')).toBe('presentation');
810810
});
811811

812812
it('should forward focus to the underlying button when the host is focused', () => {

src/material/button-toggle/button-toggle.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,14 +399,12 @@ const _MatButtonToggleMixinBase: CanDisableRippleCtor & typeof MatButtonToggleBa
399399
'[class.mat-button-toggle-disabled]': 'disabled',
400400
'[class.mat-button-toggle-appearance-standard]': 'appearance === "standard"',
401401
'class': 'mat-button-toggle',
402-
// Always reset the tabindex to -1 so it doesn't conflict with the one on the `button`,
403-
// but can still receive focus from things like cdkFocusInitial.
404-
'[attr.tabindex]': '-1',
405402
'[attr.aria-label]': 'null',
406403
'[attr.aria-labelledby]': 'null',
407404
'[attr.id]': 'id',
408405
'[attr.name]': 'null',
409406
'(focus)': 'focus()',
407+
'role': 'presentation',
410408
}
411409
})
412410
export class MatButtonToggle extends _MatButtonToggleMixinBase implements OnInit, AfterViewInit,

0 commit comments

Comments
 (0)