@@ -53,6 +53,8 @@ import {
53
53
ViewEncapsulation ,
54
54
booleanAttribute ,
55
55
inject ,
56
+ afterNextRender ,
57
+ Injector ,
56
58
} from '@angular/core' ;
57
59
import {
58
60
BehaviorSubject ,
@@ -62,7 +64,7 @@ import {
62
64
Subject ,
63
65
Subscription ,
64
66
} from 'rxjs' ;
65
- import { take , takeUntil } from 'rxjs/operators' ;
67
+ import { takeUntil } from 'rxjs/operators' ;
66
68
import { CdkColumnDef } from './cell' ;
67
69
import { _CoalescedStyleScheduler , _COALESCED_STYLE_SCHEDULER } from './coalesced-style-scheduler' ;
68
70
import {
@@ -592,6 +594,8 @@ export class CdkTable<T>
592
594
/** Row definition that will only be rendered if there's no data in the table. */
593
595
@ContentChild ( CdkNoDataRow ) _noDataRow : CdkNoDataRow ;
594
596
597
+ private _injector = inject ( Injector ) ;
598
+
595
599
constructor (
596
600
protected readonly _differs : IterableDiffers ,
597
601
protected readonly _changeDetectorRef : ChangeDetectorRef ,
@@ -614,11 +618,10 @@ export class CdkTable<T>
614
618
@Inject ( STICKY_POSITIONING_LISTENER )
615
619
protected readonly _stickyPositioningListener : StickyPositioningListener ,
616
620
/**
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
619
623
*/
620
- @Optional ( )
621
- protected readonly _ngZone ?: NgZone ,
624
+ @Optional ( ) _unusedNgZone ?: NgZone ,
622
625
) {
623
626
if ( ! role ) {
624
627
_elementRef . nativeElement . setAttribute ( 'role' , 'table' ) ;
@@ -732,15 +735,12 @@ export class CdkTable<T>
732
735
733
736
this . _updateNoDataRow ( ) ;
734
737
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
+ ( ) => {
739
740
this . updateStickyColumnStyles ( ) ;
740
- } ) ;
741
- } else {
742
- this . updateStickyColumnStyles ( ) ;
743
- }
741
+ } ,
742
+ { injector : this . _injector } ,
743
+ ) ;
744
744
745
745
this . contentChanged . next ( ) ;
746
746
}
0 commit comments