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(material/tabs): ink bar not shown in some cases #25218

Merged
merged 1 commit into from
Jul 12, 2022
Merged
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
15 changes: 10 additions & 5 deletions src/material/tabs/ink-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,16 @@ export class MatInkBar {
*/
alignToElement(element: HTMLElement) {
this.show();
this._ngZone.onStable.pipe(take(1)).subscribe(() => {
const positions = this._inkBarPositioner(element);
const inkBar: HTMLElement = this._elementRef.nativeElement;
inkBar.style.left = positions.left;
inkBar.style.width = positions.width;

// `onStable` might not run for a while if the zone has already stabilized.
// Wrap the call in `NgZone.run` to ensure that it runs relatively soon.
this._ngZone.run(() => {
this._ngZone.onStable.pipe(take(1)).subscribe(() => {
const positions = this._inkBarPositioner(element);
const inkBar = this._elementRef.nativeElement;
inkBar.style.left = positions.left;
inkBar.style.width = positions.width;
});
});
}

Expand Down