@@ -24,9 +24,6 @@ import {
2424 numberAttribute ,
2525 Output ,
2626 ANIMATION_MODULE_TYPE ,
27- afterNextRender ,
28- inject ,
29- Injector ,
3027} from '@angular/core' ;
3128import { Direction , Directionality } from '@angular/cdk/bidi' ;
3229import { ViewportRuler } from '@angular/cdk/scrolling' ;
@@ -42,7 +39,7 @@ import {
4239 timer ,
4340 fromEvent ,
4441} from 'rxjs' ;
45- import { switchMap , startWith , skip , takeUntil , filter } from 'rxjs/operators' ;
42+ import { take , switchMap , startWith , skip , takeUntil , filter } from 'rxjs/operators' ;
4643import { Platform , normalizePassiveListenerOptions } from '@angular/cdk/platform' ;
4744
4845/** Config used to bind passive event listeners */
@@ -156,8 +153,6 @@ export abstract class MatPaginatedTabHeader
156153 /** Event emitted when a label is focused. */
157154 @Output ( ) readonly indexFocused : EventEmitter < number > = new EventEmitter < number > ( ) ;
158155
159- private _injector = inject ( Injector ) ;
160-
161156 constructor (
162157 protected _elementRef : ElementRef < HTMLElement > ,
163158 protected _changeDetectorRef : ChangeDetectorRef ,
@@ -214,9 +209,9 @@ export abstract class MatPaginatedTabHeader
214209
215210 // Defer the first call in order to allow for slower browsers to lay out the elements.
216211 // This helps in cases where the user lands directly on a page with paginated tabs.
217- // TODO(mmalerba): Consider breaking this into multiple `afterNextRender` calls with explicit
218- // phase .
219- afterNextRender ( realign , { injector : this . _injector } ) ;
212+ // Note that we use `onStable` instead of `requestAnimationFrame`, because the latter
213+ // can hold up tests that are in a background tab .
214+ this . _ngZone . onStable . pipe ( take ( 1 ) ) . subscribe ( realign ) ;
220215
221216 // On dir change or window resize, realign the ink bar and update the orientation of
222217 // the key manager if the direction has changed.
0 commit comments