Skip to content

fix(material/tabs): tab nav bar animation not working when navigating forwards #30313

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

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 4 additions & 10 deletions src/material/tabs/tab-nav-bar/tab-nav-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.dev/license
*/
import {
AfterContentChecked,
AfterContentInit,
AfterViewInit,
booleanAttribute,
Expand Down Expand Up @@ -75,10 +74,7 @@ import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
changeDetection: ChangeDetectionStrategy.Default,
imports: [MatRipple, CdkObserveContent],
})
export class MatTabNav
extends MatPaginatedTabHeader
implements AfterContentChecked, AfterContentInit, OnDestroy, AfterViewInit
{
export class MatTabNav extends MatPaginatedTabHeader implements AfterContentInit, AfterViewInit {
/** Whether the ink bar should fit its width to the size of the tab label content. */
@Input({transform: booleanAttribute})
get fitInkBarToContent(): boolean {
Expand Down Expand Up @@ -194,9 +190,9 @@ export class MatTabNav
this._inkBar = new MatInkBar(this._items);
// We need this to run before the `changes` subscription in parent to ensure that the
// selectedIndex is up-to-date by the time the super class starts looking for it.
this._items.changes.pipe(startWith(null), takeUntil(this._destroyed)).subscribe(() => {
this.updateActiveLink();
});
this._items.changes
.pipe(startWith(null), takeUntil(this._destroyed))
.subscribe(() => this.updateActiveLink());

super.ngAfterContentInit();
}
Expand Down Expand Up @@ -229,9 +225,7 @@ export class MatTabNav
}
}

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

_getRole(): string | null {
Expand Down
2 changes: 1 addition & 1 deletion tools/public_api_guard/material/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export class MatTabLink extends InkBarItem implements AfterViewInit, OnDestroy,
}

// @public
export class MatTabNav extends MatPaginatedTabHeader implements AfterContentChecked, AfterContentInit, OnDestroy, AfterViewInit {
export class MatTabNav extends MatPaginatedTabHeader implements AfterContentInit, AfterViewInit {
constructor(...args: unknown[]);
// (undocumented)
get animationDuration(): string;
Expand Down
Loading