88
99import {
1010 ActiveDescendantKeyManager ,
11- LiveAnnouncer ,
1211 addAriaReferencedId ,
12+ LiveAnnouncer ,
1313 removeAriaReferencedId ,
1414} from '@angular/cdk/a11y' ;
1515import { Directionality } from '@angular/cdk/bidi' ;
@@ -35,6 +35,7 @@ import {ViewportRuler} from '@angular/cdk/scrolling';
3535import {
3636 AfterContentInit ,
3737 Attribute ,
38+ booleanAttribute ,
3839 ChangeDetectionStrategy ,
3940 ChangeDetectorRef ,
4041 Component ,
@@ -45,9 +46,11 @@ import {
4546 ElementRef ,
4647 EventEmitter ,
4748 Inject ,
49+ inject ,
4850 InjectionToken ,
4951 Input ,
5052 NgZone ,
53+ numberAttribute ,
5154 OnChanges ,
5255 OnDestroy ,
5356 OnInit ,
@@ -58,9 +61,6 @@ import {
5861 SimpleChanges ,
5962 ViewChild ,
6063 ViewEncapsulation ,
61- booleanAttribute ,
62- inject ,
63- numberAttribute ,
6464} from '@angular/core' ;
6565import {
6666 AbstractControl ,
@@ -71,17 +71,17 @@ import {
7171 Validators ,
7272} from '@angular/forms' ;
7373import {
74+ _countGroupLabelsBeforeOption ,
7475 _ErrorStateTracker ,
76+ _getOptionScrollPosition ,
7577 ErrorStateMatcher ,
78+ MAT_OPTGROUP ,
79+ MAT_OPTION_PARENT_COMPONENT ,
7680 MatOptgroup ,
7781 MatOption ,
7882 MatOptionSelectionChange ,
79- MAT_OPTGROUP ,
80- MAT_OPTION_PARENT_COMPONENT ,
81- _countGroupLabelsBeforeOption ,
82- _getOptionScrollPosition ,
8383} 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' ;
8585import { defer , merge , Observable , Subject } from 'rxjs' ;
8686import {
8787 distinctUntilChanged ,
@@ -542,6 +542,8 @@ export class MatSelect
542542 ? this . _defaultOptions . panelWidth
543543 : 'auto' ;
544544
545+ private _initialized = new Subject ( ) ;
546+
545547 /** Combined stream of all of the child options' change events. */
546548 readonly optionSelectionChanges : Observable < MatOptionSelectionChange > = defer ( ( ) => {
547549 const options = this . options ;
@@ -553,11 +555,8 @@ export class MatSelect
553555 ) ;
554556 }
555557
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+ } ) ;
561560
562561 /** Event emitted when the select panel has been toggled. */
563562 @Output ( ) readonly openedChange : EventEmitter < boolean > = new EventEmitter < boolean > ( ) ;
@@ -587,7 +586,11 @@ export class MatSelect
587586 constructor (
588587 protected _viewportRuler : ViewportRuler ,
589588 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 ,
591594 defaultErrorStateMatcher : ErrorStateMatcher ,
592595 readonly _elementRef : ElementRef ,
593596 @Optional ( ) private _dir : Directionality ,
@@ -650,6 +653,9 @@ export class MatSelect
650653 }
651654
652655 ngAfterContentInit ( ) {
656+ this . _initialized . next ( ) ;
657+ this . _initialized . complete ( ) ;
658+
653659 this . _initKeyManager ( ) ;
654660
655661 this . _selectionModel . changed . pipe ( takeUntil ( this . _destroy ) ) . subscribe ( event => {
0 commit comments