|
1 |
| -import {LEFT_ARROW} from '@angular/cdk/keycodes'; |
| 1 | +import {LEFT_ARROW, RIGHT_ARROW} from '@angular/cdk/keycodes'; |
2 | 2 | import {dispatchFakeEvent, dispatchKeyboardEvent} from '@angular/cdk/testing';
|
3 | 3 | import {Component, OnInit, QueryList, ViewChild, ViewChildren} from '@angular/core';
|
4 | 4 | import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing';
|
@@ -277,6 +277,22 @@ describe('MatTabGroup', () => {
|
277 | 277 | .toHaveBeenCalledWith(jasmine.objectContaining({index: 0}));
|
278 | 278 | });
|
279 | 279 |
|
| 280 | + it('should update the tabindex of the labels when navigating via keyboard', () => { |
| 281 | + fixture.detectChanges(); |
| 282 | + |
| 283 | + const tabLabels = fixture.debugElement.queryAll(By.css('.mat-tab-label')) |
| 284 | + .map(label => label.nativeElement); |
| 285 | + const tabLabelContainer = fixture.debugElement |
| 286 | + .query(By.css('.mat-tab-label-container')).nativeElement as HTMLElement; |
| 287 | + |
| 288 | + expect(tabLabels.map(label => label.getAttribute('tabindex'))).toEqual(['0', '-1', '-1']); |
| 289 | + |
| 290 | + dispatchKeyboardEvent(tabLabelContainer, 'keydown', RIGHT_ARROW); |
| 291 | + fixture.detectChanges(); |
| 292 | + |
| 293 | + expect(tabLabels.map(label => label.getAttribute('tabindex'))).toEqual(['-1', '0', '-1']); |
| 294 | + }); |
| 295 | + |
280 | 296 | });
|
281 | 297 |
|
282 | 298 | describe('aria labelling', () => {
|
|
0 commit comments