Skip to content

Commit

Permalink
fix(tabs): fix ink not showing on chrome 57 (#3041)
Browse files Browse the repository at this point in the history
* fixes

* remove host class

* fix tab tests
  • Loading branch information
andrewseguin authored Feb 13, 2017
1 parent 87ab712 commit f24832c
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 11 deletions.
2 changes: 0 additions & 2 deletions src/lib/tabs/_tabs-common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ $mat-tab-animation-duration: 500ms !default;
@mixin tab-header {
overflow: hidden;
position: relative;
display: flex;
flex-direction: row;
flex-shrink: 0;
}

Expand Down
4 changes: 3 additions & 1 deletion src/lib/tabs/tab-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<div class="mat-tab-label-container" #tabListContainer
(keydown)="_handleKeydown($event)">
<div class="mat-tab-list" #tabList role="tablist" (cdkObserveContent)="_onContentChanges()">
<ng-content></ng-content>
<div class="mat-tab-labels">
<ng-content></ng-content>
</div>
<md-ink-bar></md-ink-bar>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/lib/tabs/tab-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@import 'tabs-common';

.mat-tab-header {
display: flex;
@include tab-header;
}

Expand Down Expand Up @@ -78,8 +79,11 @@
}

.mat-tab-list {
display: flex;
flex-grow: 1;
position: relative;
transition: transform 500ms cubic-bezier(0.35, 0, 0.25, 1);
}

.mat-tab-labels {
display: flex;
}
2 changes: 1 addition & 1 deletion src/lib/tabs/tab-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ interface Tab {
<md-tab-header [selectedIndex]="selectedIndex"
(indexFocused)="focusedIndex = $event"
(selectFocusedIndex)="selectedIndex = $event">
<div md-tab-label-wrapper style="min-width: 30px"
<div md-tab-label-wrapper style="min-width: 30px; width: 30px"
*ngFor="let tab of tabs; let i = index"
[disabled]="!!tab.disabled"
(click)="selectedIndex = i">
Expand Down
5 changes: 4 additions & 1 deletion src/lib/tabs/tab-nav-bar/tab-nav-bar.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
<ng-content></ng-content>
<div class="mat-tab-links">
<ng-content></ng-content>
</div>

<md-ink-bar></md-ink-bar>
5 changes: 5 additions & 0 deletions src/lib/tabs/tab-nav-bar/tab-nav-bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
@include tab-header;
}

.mat-tab-links {
display: flex;
position: relative;
}

// Wraps each link in the header
.mat-tab-link {
@include tab-label;
Expand Down
25 changes: 20 additions & 5 deletions src/lib/tabs/tab-nav-bar/tab-nav-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,23 @@ import {ViewportRuler} from '../../core/overlay/position/viewport-ruler';
encapsulation: ViewEncapsulation.None,
})
export class MdTabNavBar {
_activeLinkChanged: boolean;
_activeLinkElement: ElementRef;

@ViewChild(MdInkBar) _inkBar: MdInkBar;

/** Animates the ink bar to the position of the active link element. */
updateActiveLink(element: HTMLElement) {
this._inkBar.alignToElement(element);
/** Notifies the component that the active link has been changed. */
updateActiveLink(element: ElementRef) {
this._activeLinkChanged = this._activeLinkElement != element;
this._activeLinkElement = element;
}

/** Checks if the active link has been changed and, if so, will update the ink bar. */
ngAfterContentChecked(): void {
if (this._activeLinkChanged) {
this._inkBar.alignToElement(this._activeLinkElement.nativeElement);
this._activeLinkChanged = false;
}
}
}

Expand All @@ -39,6 +51,9 @@ export class MdTabNavBar {
*/
@Directive({
selector: '[md-tab-link], [mat-tab-link]',
host: {
'[class.mat-tab-link]': 'true',
}
})
export class MdTabLink {
private _isActive: boolean = false;
Expand All @@ -49,11 +64,11 @@ export class MdTabLink {
set active(value: boolean) {
this._isActive = value;
if (value) {
this._mdTabNavBar.updateActiveLink(this._element.nativeElement);
this._mdTabNavBar.updateActiveLink(this._elementRef);
}
}

constructor(private _mdTabNavBar: MdTabNavBar, private _element: ElementRef) {}
constructor(private _mdTabNavBar: MdTabNavBar, private _elementRef: ElementRef) {}
}

/**
Expand Down

0 comments on commit f24832c

Please sign in to comment.