mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(tabs): enable keyboard wrapping and mark disabled tabs (#12218)
This commit is contained in:
committed by
Joey Perrott
parent
b5898281ca
commit
7f8fd9fc06
@@ -48,17 +48,11 @@ describe('tabs', () => {
|
||||
pressKeys(right);
|
||||
expect(await getFocusStates(tabLabels)).toEqual([false, false, true]);
|
||||
|
||||
pressKeys(right);
|
||||
expect(await getFocusStates(tabLabels)).toEqual([false, false, true]);
|
||||
|
||||
pressKeys(left);
|
||||
expect(await getFocusStates(tabLabels)).toEqual([false, true, false]);
|
||||
|
||||
pressKeys(left);
|
||||
expect(await getFocusStates(tabLabels)).toEqual([true, false, false]);
|
||||
|
||||
pressKeys(left);
|
||||
expect(await getFocusStates(tabLabels)).toEqual([true, false, false]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -284,6 +284,7 @@ describe('MatTabGroup', () => {
|
||||
fixture.detectChanges();
|
||||
const labels = fixture.debugElement.queryAll(By.css('.mat-tab-disabled'));
|
||||
expect(labels.length).toBe(1);
|
||||
expect(labels[0].nativeElement.getAttribute('aria-disabled')).toBe('true');
|
||||
});
|
||||
|
||||
it('should set the disabled flag on tab', () => {
|
||||
@@ -293,6 +294,7 @@ describe('MatTabGroup', () => {
|
||||
let labels = fixture.debugElement.queryAll(By.css('.mat-tab-disabled'));
|
||||
expect(tabs[2].disabled).toBe(false);
|
||||
expect(labels.length).toBe(1);
|
||||
expect(labels[0].nativeElement.getAttribute('aria-disabled')).toBe('true');
|
||||
|
||||
fixture.componentInstance.isDisabled = true;
|
||||
fixture.detectChanges();
|
||||
@@ -300,6 +302,8 @@ describe('MatTabGroup', () => {
|
||||
expect(tabs[2].disabled).toBe(true);
|
||||
labels = fixture.debugElement.queryAll(By.css('.mat-tab-disabled'));
|
||||
expect(labels.length).toBe(2);
|
||||
expect(labels.every(label => label.nativeElement.getAttribute('aria-disabled') === 'true'))
|
||||
.toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -198,7 +198,8 @@ export class MatTabHeader extends _MatTabHeaderMixinBase
|
||||
};
|
||||
|
||||
this._keyManager = new FocusKeyManager(this._labelWrappers)
|
||||
.withHorizontalOrientation(this._getLayoutDirection());
|
||||
.withHorizontalOrientation(this._getLayoutDirection())
|
||||
.withWrap();
|
||||
|
||||
this._keyManager.updateActiveItemIndex(0);
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ export const _MatTabLabelWrapperMixinBase = mixinDisabled(MatTabLabelWrapperBase
|
||||
selector: '[matTabLabelWrapper]',
|
||||
inputs: ['disabled'],
|
||||
host: {
|
||||
'[class.mat-tab-disabled]': 'disabled'
|
||||
'[class.mat-tab-disabled]': 'disabled',
|
||||
'[attr.aria-disabled]': '!!disabled',
|
||||
}
|
||||
})
|
||||
export class MatTabLabelWrapper extends _MatTabLabelWrapperMixinBase implements CanDisable {
|
||||
|
||||
Reference in New Issue
Block a user