fix(slide-toggle): clear tabindex from host element (#13311)

Along the same lines as #13308. Currently we forward the `tabindex` from the host to the underlying `input`, however we never clear the `tabindex` from the host, which means that we end up with two layers of focusable elements.
This commit is contained in:
Kristiyan Kostadinov
2018-10-02 19:32:44 +02:00
committed by vivian-hu
parent db873341a3
commit 119fafd3a4
2 changed files with 10 additions and 0 deletions
@@ -348,6 +348,15 @@ describe('MatSlideToggle without forms', () => {
expect(slideToggle.tabIndex)
.toBe(5, 'Expected tabIndex property to have been set based on the native attribute');
}));
it('should clear the tabindex from the host element', fakeAsync(() => {
const fixture = TestBed.createComponent(SlideToggleWithTabindexAttr);
fixture.detectChanges();
const slideToggle = fixture.debugElement.query(By.directive(MatSlideToggle)).nativeElement;
expect(slideToggle.getAttribute('tabindex')).toBeFalsy();
}));
});
describe('custom action configuration', () => {
+1
View File
@@ -85,6 +85,7 @@ export const _MatSlideToggleMixinBase:
host: {
'class': 'mat-slide-toggle',
'[id]': 'id',
'[attr.tabindex]': 'null',
'[class.mat-checked]': 'checked',
'[class.mat-disabled]': 'disabled',
'[class.mat-slide-toggle-label-before]': 'labelPosition == "before"',