mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
committed by
vivian-hu
parent
db873341a3
commit
119fafd3a4
@@ -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', () => {
|
||||
|
||||
@@ -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"',
|
||||
|
||||
Reference in New Issue
Block a user