@@ -53,6 +53,8 @@ import {
5353 ViewEncapsulation ,
5454 booleanAttribute ,
5555 inject ,
56+ afterNextRender ,
57+ Injector ,
5658} from '@angular/core' ;
5759import {
5860 BehaviorSubject ,
@@ -62,7 +64,7 @@ import {
6264 Subject ,
6365 Subscription ,
6466} from 'rxjs' ;
65- import { take , takeUntil } from 'rxjs/operators' ;
67+ import { takeUntil } from 'rxjs/operators' ;
6668import { CdkColumnDef } from './cell' ;
6769import { _CoalescedStyleScheduler , _COALESCED_STYLE_SCHEDULER } from './coalesced-style-scheduler' ;
6870import {
@@ -592,6 +594,8 @@ export class CdkTable<T>
592594 /** Row definition that will only be rendered if there's no data in the table. */
593595 @ContentChild ( CdkNoDataRow ) _noDataRow : CdkNoDataRow ;
594596
597+ private _injector = inject ( Injector ) ;
598+
595599 constructor (
596600 protected readonly _differs : IterableDiffers ,
597601 protected readonly _changeDetectorRef : ChangeDetectorRef ,
@@ -614,11 +618,10 @@ export class CdkTable<T>
614618 @Inject ( STICKY_POSITIONING_LISTENER )
615619 protected readonly _stickyPositioningListener : StickyPositioningListener ,
616620 /**
617- * @deprecated `_ngZone ` parameter to become required .
618- * @breaking -change 14 .0.0
621+ * @deprecated `_unusedNgZone ` parameter to be removed .
622+ * @breaking -change 19 .0.0
619623 */
620- @Optional ( )
621- protected readonly _ngZone ?: NgZone ,
624+ @Optional ( ) _unusedNgZone ?: NgZone ,
622625 ) {
623626 if ( ! role ) {
624627 _elementRef . nativeElement . setAttribute ( 'role' , 'table' ) ;
@@ -732,15 +735,12 @@ export class CdkTable<T>
732735
733736 this . _updateNoDataRow ( ) ;
734737
735- // Allow the new row data to render before measuring it.
736- // @breaking -change 14.0.0 Remove undefined check once _ngZone is required.
737- if ( this . _ngZone && NgZone . isInAngularZone ( ) ) {
738- this . _ngZone . onStable . pipe ( take ( 1 ) , takeUntil ( this . _onDestroy ) ) . subscribe ( ( ) => {
738+ afterNextRender (
739+ ( ) => {
739740 this . updateStickyColumnStyles ( ) ;
740- } ) ;
741- } else {
742- this . updateStickyColumnStyles ( ) ;
743- }
741+ } ,
742+ { injector : this . _injector } ,
743+ ) ;
744744
745745 this . contentChanged . next ( ) ;
746746 }
0 commit comments