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

Revert "refactor(material/tabs): Remove use of zone onStable for aligning tab header" #28764

Merged
merged 1 commit into from
Mar 25, 2024
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
13 changes: 4 additions & 9 deletions src/material/tabs/paginated-tab-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ import {
numberAttribute,
Output,
ANIMATION_MODULE_TYPE,
afterNextRender,
inject,
Injector,
} from '@angular/core';
import {Direction, Directionality} from '@angular/cdk/bidi';
import {ViewportRuler} from '@angular/cdk/scrolling';
Expand All @@ -42,7 +39,7 @@ import {
timer,
fromEvent,
} from 'rxjs';
import {switchMap, startWith, skip, takeUntil, filter} from 'rxjs/operators';
import {take, switchMap, startWith, skip, takeUntil, filter} from 'rxjs/operators';
import {Platform, normalizePassiveListenerOptions} from '@angular/cdk/platform';

/** Config used to bind passive event listeners */
Expand Down Expand Up @@ -156,8 +153,6 @@ export abstract class MatPaginatedTabHeader
/** Event emitted when a label is focused. */
@Output() readonly indexFocused: EventEmitter<number> = new EventEmitter<number>();

private _injector = inject(Injector);

constructor(
protected _elementRef: ElementRef<HTMLElement>,
protected _changeDetectorRef: ChangeDetectorRef,
Expand Down Expand Up @@ -214,9 +209,9 @@ export abstract class MatPaginatedTabHeader

// Defer the first call in order to allow for slower browsers to lay out the elements.
// This helps in cases where the user lands directly on a page with paginated tabs.
// TODO(mmalerba): Consider breaking this into multiple `afterNextRender` calls with explicit
// phase.
afterNextRender(realign, {injector: this._injector});
// Note that we use `onStable` instead of `requestAnimationFrame`, because the latter
// can hold up tests that are in a background tab.
this._ngZone.onStable.pipe(take(1)).subscribe(realign);

// On dir change or window resize, realign the ink bar and update the orientation of
// the key manager if the direction has changed.
Expand Down
Loading