Skip to content

Commit

Permalink
feat(nav-tabs): add mat-tab-label-active class to active nav tab la…
Browse files Browse the repository at this point in the history
…bels (#7508)
  • Loading branch information
josephperrott authored and kara committed Oct 5, 2017
1 parent 4a1a68d commit 00e9338
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/lib/tabs/tab-nav-bar/tab-nav-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ describe('MatTabNavBar', () => {
expect(fixture.componentInstance.activeIndex).toBe(2);
});

it('should add the active class if active', () => {
let tabLink1 = fixture.debugElement.queryAll(By.css('a'))[0];
let tabLink2 = fixture.debugElement.queryAll(By.css('a'))[1];
const tabLinkElements = fixture.debugElement.queryAll(By.css('a'))
.map(tabLinkDebugEl => tabLinkDebugEl.nativeElement);

tabLink1.nativeElement.click();
fixture.detectChanges();
expect(tabLinkElements[0].classList.contains('mat-tab-label-active')).toBeTruthy();
expect(tabLinkElements[1].classList.contains('mat-tab-label-active')).toBeFalsy();

tabLink2.nativeElement.click();
fixture.detectChanges();
expect(tabLinkElements[0].classList.contains('mat-tab-label-active')).toBeFalsy();
expect(tabLinkElements[1].classList.contains('mat-tab-label-active')).toBeTruthy();

});

it('should add the disabled class if disabled', () => {
const tabLinkElements = fixture.debugElement.queryAll(By.css('a'))
.map(tabLinkDebugEl => tabLinkDebugEl.nativeElement);
Expand Down
3 changes: 2 additions & 1 deletion src/lib/tabs/tab-nav-bar/tab-nav-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ export const _MatTabLinkMixinBase = mixinDisabled(MatTabLinkBase);
'class': 'mat-tab-link',
'[attr.aria-disabled]': 'disabled.toString()',
'[attr.tabindex]': 'tabIndex',
'[class.mat-tab-disabled]': 'disabled'
'[class.mat-tab-disabled]': 'disabled',
'[class.mat-tab-label-active]': 'active',
}
})
export class MatTabLink extends _MatTabLinkMixinBase implements OnDestroy, CanDisable {
Expand Down

0 comments on commit 00e9338

Please sign in to comment.