Skip to content

Commit cbfad6f

Browse files
committed
fix(material/tabs): tab nav bar animation not working when navigating forwards
Fixes a regression introduced in #30121. It looks like we were depending on the incorrect internal state to animate correctly. These changes fix the issue by removing a call that was redundant in the first place. Fixes #30303.
1 parent a11b03b commit cbfad6f

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
7575
changeDetection: ChangeDetectionStrategy.Default,
7676
imports: [MatRipple, CdkObserveContent],
7777
})
78-
export class MatTabNav
79-
extends MatPaginatedTabHeader
80-
implements AfterContentChecked, AfterContentInit, OnDestroy, AfterViewInit
81-
{
78+
export class MatTabNav extends MatPaginatedTabHeader implements AfterContentInit, AfterViewInit {
8279
/** Whether the ink bar should fit its width to the size of the tab label content. */
8380
@Input({transform: booleanAttribute})
8481
get fitInkBarToContent(): boolean {
@@ -194,9 +191,9 @@ export class MatTabNav
194191
this._inkBar = new MatInkBar(this._items);
195192
// We need this to run before the `changes` subscription in parent to ensure that the
196193
// selectedIndex is up-to-date by the time the super class starts looking for it.
197-
this._items.changes.pipe(startWith(null), takeUntil(this._destroyed)).subscribe(() => {
198-
this.updateActiveLink();
199-
});
194+
this._items.changes
195+
.pipe(startWith(null), takeUntil(this._destroyed))
196+
.subscribe(() => this.updateActiveLink());
200197

201198
super.ngAfterContentInit();
202199
}
@@ -229,9 +226,7 @@ export class MatTabNav
229226
}
230227
}
231228

232-
// The ink bar should hide itself if no items are active.
233229
this.selectedIndex = -1;
234-
this._inkBar.hide();
235230
}
236231

237232
_getRole(): string | null {

tools/public_api_guard/material/tabs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ export class MatTabLink extends InkBarItem implements AfterViewInit, OnDestroy,
442442
}
443443

444444
// @public
445-
export class MatTabNav extends MatPaginatedTabHeader implements AfterContentChecked, AfterContentInit, OnDestroy, AfterViewInit {
445+
export class MatTabNav extends MatPaginatedTabHeader implements AfterContentInit, AfterViewInit {
446446
constructor(...args: unknown[]);
447447
// (undocumented)
448448
get animationDuration(): string;

0 commit comments

Comments
 (0)