@@ -826,9 +826,8 @@ export class MultipleSelectInstance {
826
826
}
827
827
828
828
this . _bindEventService . bind ( this . parentElm , 'keydown' , ( ( e : KeyboardEvent ) => {
829
- if ( e . code === 'Escape' && ! this . options . keepOpen ) {
830
- this . close ( ) ;
831
- this . choiceElm . focus ( ) ;
829
+ if ( e . code === 'Escape' ) {
830
+ this . handleEscapeKey ( ) ;
832
831
}
833
832
} ) as EventListener ) ;
834
833
@@ -1037,6 +1036,9 @@ export class MultipleSelectInstance {
1037
1036
e . preventDefault ( ) ;
1038
1037
this . moveHighlightDown ( ) ;
1039
1038
break ;
1039
+ case 'Escape' :
1040
+ this . handleEscapeKey ( ) ;
1041
+ break ;
1040
1042
case 'Enter' :
1041
1043
case ' ' : {
1042
1044
// if we're focused on the OK button then don't execute following block
@@ -1073,6 +1075,7 @@ export class MultipleSelectInstance {
1073
1075
this . changeCurrentOptionHighlight ( ) ;
1074
1076
this . okButtonElm ?. focus ( ) ;
1075
1077
}
1078
+ break ;
1076
1079
}
1077
1080
}
1078
1081
} ) as EventListener ,
@@ -1086,6 +1089,13 @@ export class MultipleSelectInstance {
1086
1089
}
1087
1090
}
1088
1091
1092
+ protected handleEscapeKey ( ) {
1093
+ if ( ! this . options . keepOpen ) {
1094
+ this . close ( ) ;
1095
+ this . choiceElm . focus ( ) ;
1096
+ }
1097
+ }
1098
+
1089
1099
/**
1090
1100
* Checks if user reached the end of the list through mouse scrolling and/or arrow down,
1091
1101
* then scroll back to the top whenever that happens.
@@ -1118,14 +1128,20 @@ export class MultipleSelectInstance {
1118
1128
* The default delay is 0ms (which is 1 CPU cycle) when nothing is provided, to avoid a delay we can pass `-1` or `null`
1119
1129
* @param {number } [openDelay=0] - provide an optional delay, defaults to 0
1120
1130
*/
1121
- open ( openDelay : number | null = 0 ) {
1122
- if ( openDelay !== null && openDelay >= 0 ) {
1123
- // eslint-disable-next-line prefer-const
1124
- clearTimeout ( this . openDelayTimer ) ;
1125
- this . openDelayTimer = setTimeout ( ( ) => this . openDrop ( ) , openDelay ) ;
1126
- } else {
1127
- this . openDrop ( ) ;
1128
- }
1131
+ open ( openDelay : number | null = 0 ) : Promise < void > {
1132
+ return new Promise ( resolve => {
1133
+ if ( openDelay !== null && openDelay >= 0 ) {
1134
+ // eslint-disable-next-line prefer-const
1135
+ clearTimeout ( this . openDelayTimer ) ;
1136
+ this . openDelayTimer = setTimeout ( ( ) => {
1137
+ this . openDrop ( ) ;
1138
+ resolve ( ) ;
1139
+ } , openDelay ) ;
1140
+ } else {
1141
+ this . openDrop ( ) ;
1142
+ resolve ( ) ;
1143
+ }
1144
+ } ) ;
1129
1145
}
1130
1146
1131
1147
protected openDrop ( ) {
0 commit comments