@@ -757,11 +757,8 @@ export class MatSelect
757757 // Required for the MDC form field to pick up when the overlay has been opened.
758758 this . stateChanges . next ( ) ;
759759
760- // This usually fires at the end of the animation,
761- // but that won't happen if animations are disabled.
762- if ( this . _animationsDisabled ) {
763- this . openedChange . emit ( true ) ;
764- }
760+ // Simulate the animation event before we moved away from `@angular/animations`.
761+ Promise . resolve ( ) . then ( ( ) => this . openedChange . emit ( true ) ) ;
765762 }
766763
767764 /**
@@ -839,6 +836,9 @@ export class MatSelect
839836 this . _onTouched ( ) ;
840837 // Required for the MDC form field to pick up when the overlay has been closed.
841838 this . stateChanges . next ( ) ;
839+
840+ // Simulate the animation event before we moved away from `@angular/animations`.
841+ Promise . resolve ( ) . then ( ( ) => this . openedChange . emit ( false ) ) ;
842842 }
843843 }
844844
@@ -1006,7 +1006,7 @@ export class MatSelect
10061006 const isArrowKey = keyCode === DOWN_ARROW || keyCode === UP_ARROW ;
10071007 const isTyping = manager . isTyping ( ) ;
10081008
1009- if ( ( isArrowKey && event . altKey ) || ( keyCode === ESCAPE && ! hasModifierKey ( event ) ) ) {
1009+ if ( isArrowKey && event . altKey ) {
10101010 // Close the select on ALT + arrow key to match the native <select>
10111011 event . preventDefault ( ) ;
10121012 this . close ( ) ;
@@ -1046,6 +1046,18 @@ export class MatSelect
10461046 }
10471047 }
10481048
1049+ /** Handles keyboard events coming from the overlay. */
1050+ protected _handleOverlayKeydown ( event : KeyboardEvent ) : void {
1051+ // TODO(crisbeto): prior to #30363 this was being handled inside the overlay directive, but we
1052+ // need control over the animation timing so we do it manually. We should remove the `keydown`
1053+ // listener from `.mat-mdc-select-panel` and handle all the events here. That may cause
1054+ // further test breakages so it's left for a follow-up.
1055+ if ( event . keyCode === ESCAPE && ! hasModifierKey ( event ) ) {
1056+ event . preventDefault ( ) ;
1057+ this . close ( ) ;
1058+ }
1059+ }
1060+
10491061 _onFocus ( ) {
10501062 if ( ! this . disabled ) {
10511063 this . _focused = true ;
@@ -1078,13 +1090,6 @@ export class MatSelect
10781090 return ! this . _selectionModel || this . _selectionModel . isEmpty ( ) ;
10791091 }
10801092
1081- /** Handles animation events from the panel. */
1082- protected _handleAnimationEndEvent ( event : AnimationEvent ) {
1083- if ( event . target === this . panel . nativeElement && event . animationName === '_mat-select-enter' ) {
1084- this . openedChange . emit ( true ) ;
1085- }
1086- }
1087-
10881093 private _initializeSelection ( ) : void {
10891094 // Defer setting the value in order to avoid the "Expression
10901095 // has changed after it was checked" errors from Angular.
0 commit comments