@@ -22,7 +22,10 @@ import {DOCUMENT} from '@angular/common';
22
22
import {
23
23
AfterContentChecked ,
24
24
AfterContentInit ,
25
+ afterNextRender ,
26
+ AfterRenderPhase ,
25
27
AfterViewInit ,
28
+ ANIMATION_MODULE_TYPE ,
26
29
ChangeDetectionStrategy ,
27
30
ChangeDetectorRef ,
28
31
Component ,
@@ -32,8 +35,10 @@ import {
32
35
ElementRef ,
33
36
EventEmitter ,
34
37
forwardRef ,
38
+ inject ,
35
39
Inject ,
36
40
InjectionToken ,
41
+ Injector ,
37
42
Input ,
38
43
NgZone ,
39
44
OnDestroy ,
@@ -42,18 +47,17 @@ import {
42
47
QueryList ,
43
48
ViewChild ,
44
49
ViewEncapsulation ,
45
- ANIMATION_MODULE_TYPE ,
46
50
} from '@angular/core' ;
47
51
import { fromEvent , merge , Observable , Subject } from 'rxjs' ;
48
52
import {
49
53
debounceTime ,
54
+ distinctUntilChanged ,
50
55
filter ,
51
56
map ,
57
+ mapTo ,
52
58
startWith ,
53
59
take ,
54
60
takeUntil ,
55
- distinctUntilChanged ,
56
- mapTo ,
57
61
} from 'rxjs/operators' ;
58
62
import { matDrawerAnimations } from './drawer-animations' ;
59
63
@@ -750,6 +754,8 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy
750
754
return this . _userContent || this . _content ;
751
755
}
752
756
757
+ private _injector = inject ( Injector ) ;
758
+
753
759
constructor (
754
760
@Optional ( ) private _dir : Directionality ,
755
761
private _element : ElementRef < HTMLElement > ,
@@ -933,9 +939,12 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy
933
939
// NOTE: We need to wait for the microtask queue to be empty before validating,
934
940
// since both drawers may be swapping positions at the same time.
935
941
drawer . onPositionChanged . pipe ( takeUntil ( this . _drawers . changes ) ) . subscribe ( ( ) => {
936
- this . _ngZone . onMicrotaskEmpty . pipe ( take ( 1 ) ) . subscribe ( ( ) => {
937
- this . _validateDrawers ( ) ;
938
- } ) ;
942
+ afterNextRender (
943
+ ( ) => {
944
+ this . _validateDrawers ( ) ;
945
+ } ,
946
+ { injector : this . _injector , phase : AfterRenderPhase . Read } ,
947
+ ) ;
939
948
} ) ;
940
949
}
941
950
0 commit comments