8
8
9
9
import {
10
10
ActiveDescendantKeyManager ,
11
- LiveAnnouncer ,
12
11
addAriaReferencedId ,
12
+ LiveAnnouncer ,
13
13
removeAriaReferencedId ,
14
14
} from '@angular/cdk/a11y' ;
15
15
import { Directionality } from '@angular/cdk/bidi' ;
@@ -35,6 +35,7 @@ import {ViewportRuler} from '@angular/cdk/scrolling';
35
35
import {
36
36
AfterContentInit ,
37
37
Attribute ,
38
+ booleanAttribute ,
38
39
ChangeDetectionStrategy ,
39
40
ChangeDetectorRef ,
40
41
Component ,
@@ -45,9 +46,11 @@ import {
45
46
ElementRef ,
46
47
EventEmitter ,
47
48
Inject ,
49
+ inject ,
48
50
InjectionToken ,
49
51
Input ,
50
52
NgZone ,
53
+ numberAttribute ,
51
54
OnChanges ,
52
55
OnDestroy ,
53
56
OnInit ,
@@ -58,9 +61,6 @@ import {
58
61
SimpleChanges ,
59
62
ViewChild ,
60
63
ViewEncapsulation ,
61
- booleanAttribute ,
62
- inject ,
63
- numberAttribute ,
64
64
} from '@angular/core' ;
65
65
import {
66
66
AbstractControl ,
@@ -71,17 +71,17 @@ import {
71
71
Validators ,
72
72
} from '@angular/forms' ;
73
73
import {
74
+ _countGroupLabelsBeforeOption ,
74
75
_ErrorStateTracker ,
76
+ _getOptionScrollPosition ,
75
77
ErrorStateMatcher ,
78
+ MAT_OPTGROUP ,
79
+ MAT_OPTION_PARENT_COMPONENT ,
76
80
MatOptgroup ,
77
81
MatOption ,
78
82
MatOptionSelectionChange ,
79
- MAT_OPTGROUP ,
80
- MAT_OPTION_PARENT_COMPONENT ,
81
- _countGroupLabelsBeforeOption ,
82
- _getOptionScrollPosition ,
83
83
} from '@angular/material/core' ;
84
- import { MatFormField , MatFormFieldControl , MAT_FORM_FIELD } from '@angular/material/form-field' ;
84
+ import { MAT_FORM_FIELD , MatFormField , MatFormFieldControl } from '@angular/material/form-field' ;
85
85
import { defer , merge , Observable , Subject } from 'rxjs' ;
86
86
import {
87
87
distinctUntilChanged ,
@@ -542,6 +542,8 @@ export class MatSelect
542
542
? this . _defaultOptions . panelWidth
543
543
: 'auto' ;
544
544
545
+ private _initialized = new Subject ( ) ;
546
+
545
547
/** Combined stream of all of the child options' change events. */
546
548
readonly optionSelectionChanges : Observable < MatOptionSelectionChange > = defer ( ( ) => {
547
549
const options = this . options ;
@@ -553,11 +555,8 @@ export class MatSelect
553
555
) ;
554
556
}
555
557
556
- return this . _ngZone . onStable . pipe (
557
- take ( 1 ) ,
558
- switchMap ( ( ) => this . optionSelectionChanges ) ,
559
- ) ;
560
- } ) as Observable < MatOptionSelectionChange > ;
558
+ return this . _initialized . pipe ( switchMap ( ( ) => this . optionSelectionChanges ) ) ;
559
+ } ) ;
561
560
562
561
/** Event emitted when the select panel has been toggled. */
563
562
@Output ( ) readonly openedChange : EventEmitter < boolean > = new EventEmitter < boolean > ( ) ;
@@ -587,7 +586,11 @@ export class MatSelect
587
586
constructor (
588
587
protected _viewportRuler : ViewportRuler ,
589
588
protected _changeDetectorRef : ChangeDetectorRef ,
590
- protected _ngZone : NgZone ,
589
+ /**
590
+ * @deprecated Unused param, will be removed.
591
+ * @breaking -change 19.0.0
592
+ */
593
+ _unusedNgZone : NgZone ,
591
594
defaultErrorStateMatcher : ErrorStateMatcher ,
592
595
readonly _elementRef : ElementRef ,
593
596
@Optional ( ) private _dir : Directionality ,
@@ -650,6 +653,9 @@ export class MatSelect
650
653
}
651
654
652
655
ngAfterContentInit ( ) {
656
+ this . _initialized . next ( ) ;
657
+ this . _initialized . complete ( ) ;
658
+
653
659
this . _initKeyManager ( ) ;
654
660
655
661
this . _selectionModel . changed . pipe ( takeUntil ( this . _destroy ) ) . subscribe ( event => {
0 commit comments