File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,9 @@ const OptionList: React.RefForwardingComponent<
218
218
// >>> Close
219
219
case KeyCode . ESC : {
220
220
onToggleOpen ( false ) ;
221
+ if ( open ) {
222
+ event . stopPropagation ( ) ;
223
+ }
221
224
}
222
225
}
223
226
} ,
Original file line number Diff line number Diff line change @@ -666,7 +666,12 @@ describe('Select.Basic', () => {
666
666
} ) ;
667
667
668
668
it ( 'close on ESC' , ( ) => {
669
- const wrapper = mount ( < Select /> ) ;
669
+ const onKeyDown = jest . fn ( ) ;
670
+ const wrapper = mount (
671
+ < div onKeyDown = { onKeyDown } >
672
+ < Select />
673
+ </ div > ,
674
+ ) ;
670
675
toggleOpen ( wrapper ) ;
671
676
wrapper
672
677
. find ( 'input' )
@@ -677,6 +682,12 @@ describe('Select.Basic', () => {
677
682
678
683
expect ( wrapper . find ( 'input' ) . props ( ) . value ) . toBe ( '' ) ;
679
684
expectOpen ( wrapper , false ) ;
685
+ expect ( onKeyDown ) . toHaveBeenCalledTimes ( 0 ) ;
686
+
687
+ // should keep propagation when optionList is closed
688
+ wrapper . simulate ( 'keyDown' , { which : KeyCode . ESC } ) ;
689
+ wrapper . update ( ) ;
690
+ expect ( onKeyDown ) . toHaveBeenCalledTimes ( 1 ) ;
680
691
} ) ;
681
692
682
693
it ( 'close after select' , ( ) => {
You can’t perform that action at this time.
0 commit comments