@@ -513,14 +513,6 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
513
513
this . _resetOptions ( ) ;
514
514
this . _initializeSelection ( ) ;
515
515
} ) ;
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
- } ) ;
524
516
}
525
517
526
518
ngDoCheck ( ) {
@@ -558,31 +550,26 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
558
550
// Note: The computed font-size will be a string pixel value (e.g. "16px").
559
551
// `parseInt` ignores the trailing 'px' and converts this to a number.
560
552
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
+ }
561
557
562
558
this . _panelOpen = true ;
563
559
this . _keyManager . withHorizontalOrientation ( null ) ;
564
560
this . _calculateOverlayPosition ( ) ;
565
561
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` } ) ;
568
564
if ( this . _dir ) {
569
565
this . overlayDir . overlayRef . setDirection ( this . _dir ) ;
570
566
}
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 ( ) ;
581
568
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 ( ) ;
586
573
}
587
574
588
575
/** Closes the overlay panel and focuses the host element. */
@@ -672,6 +659,12 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
672
659
return this . _selectionModel . selected [ 0 ] . viewValue ;
673
660
}
674
661
662
+ /** The animation transform for overlay panel. */
663
+ get _transformPanel ( ) {
664
+ return this . panelOpen ? ( this . multiple ? 'showing-multiple' : 'showing' ) : 'void'
665
+ }
666
+
667
+
675
668
/** Whether the element is in RTL mode. */
676
669
_isRtl ( ) : boolean {
677
670
return this . _dir ? this . _dir . value === 'rtl' : false ;
@@ -769,6 +762,7 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
769
762
this . _changeDetectorRef . detectChanges ( ) ;
770
763
this . _calculateOverlayOffsetX ( ) ;
771
764
this . panel . nativeElement . scrollTop = this . _scrollTop ;
765
+ this . _hideBackdrop ( ) ;
772
766
} ) ;
773
767
}
774
768
@@ -796,31 +790,6 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
796
790
}
797
791
}
798
792
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
-
824
793
private _initializeSelection ( ) : void {
825
794
// Defer setting the value in order to avoid the "Expression
826
795
// has changed after it was checked" errors from Angular.
0 commit comments