@@ -24,6 +24,9 @@ import {
24
24
numberAttribute ,
25
25
Output ,
26
26
ANIMATION_MODULE_TYPE ,
27
+ afterNextRender ,
28
+ inject ,
29
+ Injector ,
27
30
} from '@angular/core' ;
28
31
import { Direction , Directionality } from '@angular/cdk/bidi' ;
29
32
import { ViewportRuler } from '@angular/cdk/scrolling' ;
@@ -39,7 +42,7 @@ import {
39
42
timer ,
40
43
fromEvent ,
41
44
} from 'rxjs' ;
42
- import { take , switchMap , startWith , skip , takeUntil , filter } from 'rxjs/operators' ;
45
+ import { switchMap , startWith , skip , takeUntil , filter } from 'rxjs/operators' ;
43
46
import { Platform , normalizePassiveListenerOptions } from '@angular/cdk/platform' ;
44
47
45
48
/** Config used to bind passive event listeners */
@@ -153,6 +156,8 @@ export abstract class MatPaginatedTabHeader
153
156
/** Event emitted when a label is focused. */
154
157
@Output ( ) readonly indexFocused : EventEmitter < number > = new EventEmitter < number > ( ) ;
155
158
159
+ private _injector = inject ( Injector ) ;
160
+
156
161
constructor (
157
162
protected _elementRef : ElementRef < HTMLElement > ,
158
163
protected _changeDetectorRef : ChangeDetectorRef ,
@@ -209,9 +214,9 @@ export abstract class MatPaginatedTabHeader
209
214
210
215
// Defer the first call in order to allow for slower browsers to lay out the elements.
211
216
// This helps in cases where the user lands directly on a page with paginated tabs.
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 ) ;
217
+ // TODO(mmalerba): Consider breaking this into multiple `afterNextRender` calls with explicit
218
+ // phase .
219
+ afterNextRender ( realign , { injector : this . _injector } ) ;
215
220
216
221
// On dir change or window resize, realign the ink bar and update the orientation of
217
222
// the key manager if the direction has changed.
0 commit comments