Skip to content

Commit f24832c

Browse files
authored
fix(tabs): fix ink not showing on chrome 57 (#3041)
* fixes * remove host class * fix tab tests
1 parent 87ab712 commit f24832c

File tree

7 files changed

+38
-11
lines changed

7 files changed

+38
-11
lines changed

src/lib/tabs/_tabs-common.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ $mat-tab-animation-duration: 500ms !default;
2828
@mixin tab-header {
2929
overflow: hidden;
3030
position: relative;
31-
display: flex;
32-
flex-direction: row;
3331
flex-shrink: 0;
3432
}
3533

src/lib/tabs/tab-header.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
<div class="mat-tab-label-container" #tabListContainer
1010
(keydown)="_handleKeydown($event)">
1111
<div class="mat-tab-list" #tabList role="tablist" (cdkObserveContent)="_onContentChanges()">
12-
<ng-content></ng-content>
12+
<div class="mat-tab-labels">
13+
<ng-content></ng-content>
14+
</div>
1315
<md-ink-bar></md-ink-bar>
1416
</div>
1517
</div>

src/lib/tabs/tab-header.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@import 'tabs-common';
44

55
.mat-tab-header {
6+
display: flex;
67
@include tab-header;
78
}
89

@@ -78,8 +79,11 @@
7879
}
7980

8081
.mat-tab-list {
81-
display: flex;
8282
flex-grow: 1;
8383
position: relative;
8484
transition: transform 500ms cubic-bezier(0.35, 0, 0.25, 1);
85+
}
86+
87+
.mat-tab-labels {
88+
display: flex;
8589
}

src/lib/tabs/tab-header.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ interface Tab {
216216
<md-tab-header [selectedIndex]="selectedIndex"
217217
(indexFocused)="focusedIndex = $event"
218218
(selectFocusedIndex)="selectedIndex = $event">
219-
<div md-tab-label-wrapper style="min-width: 30px"
219+
<div md-tab-label-wrapper style="min-width: 30px; width: 30px"
220220
*ngFor="let tab of tabs; let i = index"
221221
[disabled]="!!tab.disabled"
222222
(click)="selectedIndex = i">
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
<ng-content></ng-content>
1+
<div class="mat-tab-links">
2+
<ng-content></ng-content>
3+
</div>
4+
25
<md-ink-bar></md-ink-bar>

src/lib/tabs/tab-nav-bar/tab-nav-bar.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
@include tab-header;
77
}
88

9+
.mat-tab-links {
10+
display: flex;
11+
position: relative;
12+
}
13+
914
// Wraps each link in the header
1015
.mat-tab-link {
1116
@include tab-label;

src/lib/tabs/tab-nav-bar/tab-nav-bar.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,23 @@ import {ViewportRuler} from '../../core/overlay/position/viewport-ruler';
2626
encapsulation: ViewEncapsulation.None,
2727
})
2828
export class MdTabNavBar {
29+
_activeLinkChanged: boolean;
30+
_activeLinkElement: ElementRef;
31+
2932
@ViewChild(MdInkBar) _inkBar: MdInkBar;
3033

31-
/** Animates the ink bar to the position of the active link element. */
32-
updateActiveLink(element: HTMLElement) {
33-
this._inkBar.alignToElement(element);
34+
/** Notifies the component that the active link has been changed. */
35+
updateActiveLink(element: ElementRef) {
36+
this._activeLinkChanged = this._activeLinkElement != element;
37+
this._activeLinkElement = element;
38+
}
39+
40+
/** Checks if the active link has been changed and, if so, will update the ink bar. */
41+
ngAfterContentChecked(): void {
42+
if (this._activeLinkChanged) {
43+
this._inkBar.alignToElement(this._activeLinkElement.nativeElement);
44+
this._activeLinkChanged = false;
45+
}
3446
}
3547
}
3648

@@ -39,6 +51,9 @@ export class MdTabNavBar {
3951
*/
4052
@Directive({
4153
selector: '[md-tab-link], [mat-tab-link]',
54+
host: {
55+
'[class.mat-tab-link]': 'true',
56+
}
4257
})
4358
export class MdTabLink {
4459
private _isActive: boolean = false;
@@ -49,11 +64,11 @@ export class MdTabLink {
4964
set active(value: boolean) {
5065
this._isActive = value;
5166
if (value) {
52-
this._mdTabNavBar.updateActiveLink(this._element.nativeElement);
67+
this._mdTabNavBar.updateActiveLink(this._elementRef);
5368
}
5469
}
5570

56-
constructor(private _mdTabNavBar: MdTabNavBar, private _element: ElementRef) {}
71+
constructor(private _mdTabNavBar: MdTabNavBar, private _elementRef: ElementRef) {}
5772
}
5873

5974
/**

0 commit comments

Comments
 (0)