@@ -757,11 +757,8 @@ export class MatSelect
757
757
// Required for the MDC form field to pick up when the overlay has been opened.
758
758
this . stateChanges . next ( ) ;
759
759
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 ) ) ;
765
762
}
766
763
767
764
/**
@@ -839,6 +836,9 @@ export class MatSelect
839
836
this . _onTouched ( ) ;
840
837
// Required for the MDC form field to pick up when the overlay has been closed.
841
838
this . stateChanges . next ( ) ;
839
+
840
+ // Simulate the animation event before we moved away from `@angular/animations`.
841
+ Promise . resolve ( ) . then ( ( ) => this . openedChange . emit ( false ) ) ;
842
842
}
843
843
}
844
844
@@ -1006,7 +1006,7 @@ export class MatSelect
1006
1006
const isArrowKey = keyCode === DOWN_ARROW || keyCode === UP_ARROW ;
1007
1007
const isTyping = manager . isTyping ( ) ;
1008
1008
1009
- if ( ( isArrowKey && event . altKey ) || ( keyCode === ESCAPE && ! hasModifierKey ( event ) ) ) {
1009
+ if ( isArrowKey && event . altKey ) {
1010
1010
// Close the select on ALT + arrow key to match the native <select>
1011
1011
event . preventDefault ( ) ;
1012
1012
this . close ( ) ;
@@ -1046,6 +1046,18 @@ export class MatSelect
1046
1046
}
1047
1047
}
1048
1048
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
+
1049
1061
_onFocus ( ) {
1050
1062
if ( ! this . disabled ) {
1051
1063
this . _focused = true ;
@@ -1078,13 +1090,6 @@ export class MatSelect
1078
1090
return ! this . _selectionModel || this . _selectionModel . isEmpty ( ) ;
1079
1091
}
1080
1092
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
-
1088
1093
private _initializeSelection ( ) : void {
1089
1094
// Defer setting the value in order to avoid the "Expression
1090
1095
// has changed after it was checked" errors from Angular.
0 commit comments