Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tabs): fix ink not showing on chrome 57 #3041

Merged
merged 3 commits into from
Feb 13, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we can't do this in the updateActiveLink method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial set for active is performed while the component is setting up and before the content is ready, so the ink bar doesn't know what to align to. Subsequent calls would be fine but we're seeing an issue with the first load of the component.

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