Bug (Some different than https://github.com/angular/material2/issues/3044)
Highlighter [md-ink-bar] should invalidate position on init app
Misaligned [md-ink-bar]. Please see attached image.
_Case 1_
_Case 2_ (or _just apply attached git patch._ )
Providing a Plunker (or similar) is the best way to get the team to see your issue.
Patch: MD_TabBar_issue.patch.zip
Based on up to date sources of material2

Same here on iOS 10.3.2 cordova app
Hi,
Any plans to fix this?
Is there a workarond for this?
I have this workarond
@ViewChild(MatTabNav) public matTabNav: MatTabNav;
public ngAfterViewChecked(): void {
setTimeout(() => this.matTabNav._alignInkBar(), 0);
}
This has changed to _alignInkBarToSelectedTab in Angular 8
This is happening to me, because my sidebar for the entire app has a width change on route change, so if I have a mat-tab-group in any page, I would have to implement this, which means, I would have to do this in over 10+ pages. This workaround is not a good fix for my use-case. Is there another fix, globally?
I also have ran into this issue. The mat-ink-bar does not recalculate when there is a material side nav with the mode set to "side". Here is my work around with css (I am hiding the mat-ink-bar and using &:after styling):
.mat-tab-label-active {
.mat-tab-label-content {
font-weight: bold;
color: black;
&:after {
content: '';
display: block;
position: absolute;
width: 100%;
height: 2px;
background: $blue-3;
right: 0;
bottom: 0;
}
}
}
mat-ink-bar {
display: none !important;
}
So it does not work till now.
Workaround by @Anderman with ngAfterViewChecked() works but might cause performance problems.
In my case content loads, and causes a vertical scrollbar, it resizes the page a bit (but window.onresize doesn't catch this resize event, so can't catch it yet), and sets the wrong alignment to mat-ink. My workaround - listen for routing event, wait for content loading by setTimeout with 1sec delay and realign mat-ink. But it is awful :) wait for a better neat solution
@ViewChild('matTabsRef', { static: false }) matTabsRef: MatTabNav;
fixResizeInkBar() {
setTimeout(() => {
if (this.matTabsRef) {
this.matTabsRef._alignInkBarToSelectedTab();
}
}, 1000);
}
private listenRoutes(): void {
this.subs.add(
this.router.events
.pipe(
filter((event) => event instanceof NavigationEnd),
startWith(true)
)
.subscribe((event) => {
this.fixResizeInkBar();
})
);
}
Most helpful comment
This has changed to
_alignInkBarToSelectedTabin Angular 8