@@ -34,8 +34,6 @@ import {
3434import { ViewportRuler } from '@angular/cdk/scrolling' ;
3535import {
3636 AfterContentInit ,
37- afterNextRender ,
38- AfterRenderPhase ,
3937 Attribute ,
4038 booleanAttribute ,
4139 ChangeDetectionStrategy ,
@@ -50,7 +48,6 @@ import {
5048 Inject ,
5149 inject ,
5250 InjectionToken ,
53- Injector ,
5451 Input ,
5552 NgZone ,
5653 numberAttribute ,
@@ -545,6 +542,8 @@ export class MatSelect
545542 ? this . _defaultOptions . panelWidth
546543 : 'auto' ;
547544
545+ private _initialized = new Subject ( ) ;
546+
548547 /** Combined stream of all of the child options' change events. */
549548 readonly optionSelectionChanges : Observable < MatOptionSelectionChange > = defer ( ( ) => {
550549 const options = this . options ;
@@ -556,19 +555,8 @@ export class MatSelect
556555 ) ;
557556 }
558557
559- return new Observable ( subscriber => {
560- afterNextRender (
561- ( ) => {
562- subscriber . next ( ) ;
563- subscriber . complete ( ) ;
564- } ,
565- {
566- injector : this . _injector ,
567- phase : AfterRenderPhase . Read ,
568- } ,
569- ) ;
570- } ) . pipe ( switchMap ( ( ) => this . optionSelectionChanges ) ) ;
571- } ) as Observable < MatOptionSelectionChange > ;
558+ return this . _initialized . pipe ( switchMap ( ( ) => this . optionSelectionChanges ) ) ;
559+ } ) ;
572560
573561 /** Event emitted when the select panel has been toggled. */
574562 @Output ( ) readonly openedChange : EventEmitter < boolean > = new EventEmitter < boolean > ( ) ;
@@ -595,8 +583,6 @@ export class MatSelect
595583 */
596584 @Output ( ) readonly valueChange : EventEmitter < any > = new EventEmitter < any > ( ) ;
597585
598- private _injector = inject ( Injector ) ;
599-
600586 constructor (
601587 protected _viewportRuler : ViewportRuler ,
602588 protected _changeDetectorRef : ChangeDetectorRef ,
@@ -667,6 +653,9 @@ export class MatSelect
667653 }
668654
669655 ngAfterContentInit ( ) {
656+ this . _initialized . next ( ) ;
657+ this . _initialized . complete ( ) ;
658+
670659 this . _initKeyManager ( ) ;
671660
672661 this . _selectionModel . changed . pipe ( takeUntil ( this . _destroy ) ) . subscribe ( event => {
0 commit comments