@@ -513,14 +513,6 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
513513 this . _resetOptions ( ) ;
514514 this . _initializeSelection ( ) ;
515515 } ) ;
516-
517- this . _triggerRect = this . trigger . nativeElement . getBoundingClientRect ( ) ;
518-
519- // Defer setting the value in order to void the "Expression has changed after it was checked"
520- // errors from Angular
521- Promise . resolve ( ) . then ( ( ) => {
522- this . _initializePanel ( ) ;
523- } ) ;
524516 }
525517
526518 ngDoCheck ( ) {
@@ -558,31 +550,26 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
558550 // Note: The computed font-size will be a string pixel value (e.g. "16px").
559551 // `parseInt` ignores the trailing 'px' and converts this to a number.
560552 this . _triggerFontSize = parseInt ( getComputedStyle ( this . trigger . nativeElement ) [ 'font-size' ] ) ;
553+ if ( this . _triggerFontSize && this . overlayDir . overlayRef &&
554+ this . overlayDir . overlayRef . overlayElement ) {
555+ this . overlayDir . overlayRef . overlayElement . style . fontSize = `${ this . _triggerFontSize } px` ;
556+ }
561557
562558 this . _panelOpen = true ;
563559 this . _keyManager . withHorizontalOrientation ( null ) ;
564560 this . _calculateOverlayPosition ( ) ;
565561 this . _highlightCorrectOption ( ) ;
566- this . _showBackdrop ( ) ;
567- this . overlayDir . overlayRef . overlayElement . style . minWidth = `${ this . _triggerRect . width } px` ;
562+
563+ this . overlayDir . overlayRef . updateSize ( { minWidth : `${ this . _triggerRect . width } px` } ) ;
568564 if ( this . _dir ) {
569565 this . overlayDir . overlayRef . setDirection ( this . _dir ) ;
570566 }
571- this . _changeDetectorRef . markForCheck ( ) ;
572-
573- // Set the font size on the panel element once it exists.
574- this . _ngZone . onStable . asObservable ( ) . pipe ( take ( 1 ) ) . subscribe ( ( ) => {
575- if ( this . _triggerFontSize && this . overlayDir . overlayRef &&
576- this . overlayDir . overlayRef . overlayElement ) {
577- this . overlayDir . overlayRef . overlayElement . style . fontSize = `${ this . _triggerFontSize } px` ;
578- }
579-
580- this . overlayDir . overlayRef . updatePosition ( ) ;
567+ this . overlayDir . overlayRef . updatePosition ( ) ;
581568
582- this . _changeDetectorRef . detectChanges ( ) ;
583- this . _calculateOverlayOffsetX ( ) ;
584- this . panel . nativeElement . scrollTop = this . _scrollTop ;
585- } ) ;
569+ this . _changeDetectorRef . detectChanges ( ) ;
570+ this . _calculateOverlayOffsetX ( ) ;
571+ this . panel . nativeElement . scrollTop = this . _scrollTop ;
572+ this . _showBackdrop ( ) ;
586573 }
587574
588575 /** Closes the overlay panel and focuses the host element. */
@@ -672,6 +659,12 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
672659 return this . _selectionModel . selected [ 0 ] . viewValue ;
673660 }
674661
662+ /** The animation transform for overlay panel. */
663+ get _transformPanel ( ) {
664+ return this . panelOpen ? ( this . multiple ? 'showing-multiple' : 'showing' ) : 'void'
665+ }
666+
667+
675668 /** Whether the element is in RTL mode. */
676669 _isRtl ( ) : boolean {
677670 return this . _dir ? this . _dir . value === 'rtl' : false ;
@@ -769,6 +762,7 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
769762 this . _changeDetectorRef . detectChanges ( ) ;
770763 this . _calculateOverlayOffsetX ( ) ;
771764 this . panel . nativeElement . scrollTop = this . _scrollTop ;
765+ this . _hideBackdrop ( ) ;
772766 } ) ;
773767 }
774768
@@ -796,31 +790,6 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
796790 }
797791 }
798792
799- /** Initialize the overlay panel, and make it invisible. */
800- private _initializePanel ( ) {
801- if ( this . disabled || ! this . options || ! this . options . length ) {
802- return ;
803- }
804-
805- this . _triggerRect = this . trigger . nativeElement . getBoundingClientRect ( ) ;
806- // Note: The computed font-size will be a string pixel value (e.g. "16px").
807- // `parseInt` ignores the trailing 'px' and converts this to a number.
808- this . _triggerFontSize = parseInt ( getComputedStyle ( this . trigger . nativeElement ) [ 'font-size' ] ) ;
809-
810- this . _calculateOverlayPosition ( ) ;
811- this . _changeDetectorRef . markForCheck ( ) ;
812-
813- // Set the font size on the panel element once it exists.
814- this . _ngZone . onStable . asObservable ( ) . pipe ( take ( 1 ) ) . subscribe ( ( ) => {
815- if ( this . _triggerFontSize && this . overlayDir . overlayRef &&
816- this . overlayDir . overlayRef . overlayElement ) {
817- this . overlayDir . overlayRef . overlayElement . style . fontSize = `${ this . _triggerFontSize } px` ;
818- }
819-
820- this . _hideBackdrop ( ) ;
821- } ) ;
822- }
823-
824793 private _initializeSelection ( ) : void {
825794 // Defer setting the value in order to avoid the "Expression
826795 // has changed after it was checked" errors from Angular.
0 commit comments