File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,10 @@ function Dropdown({
248
248
return ;
249
249
}
250
250
251
+ if ( ! menuRef . current && key === 'Tab' ) {
252
+ return ;
253
+ }
254
+
251
255
lastSourceEvent . current = event . type ;
252
256
253
257
switch ( key ) {
Original file line number Diff line number Diff line change @@ -335,6 +335,26 @@ describe('<Dropdown>', () => {
335
335
} ) ;
336
336
} ) ;
337
337
338
+ it ( 'should not call onToggle if the menu is not open and "tab" is pressed' , ( ) => {
339
+ const onToggleSpy = sinon . spy ( ) ;
340
+ const wrapper = mount ( < SimpleDropdown onToggle = { onToggleSpy } /> , {
341
+ attachTo : focusableContainer ,
342
+ } ) ;
343
+
344
+ const toggle = wrapper . find ( '.toggle' ) . getDOMNode ( ) ;
345
+ toggle . focus ( ) ;
346
+
347
+ simulant . fire ( toggle , 'keydown' , {
348
+ key : 'Tab' ,
349
+ } ) ;
350
+
351
+ simulant . fire ( document , 'keyup' , {
352
+ key : 'Tab' ,
353
+ } ) ;
354
+
355
+ onToggleSpy . should . not . be . called ;
356
+ } ) ;
357
+
338
358
describe ( 'popper config' , ( ) => {
339
359
it ( 'can add modifiers' , ( done ) => {
340
360
const spy = sinon . spy ( ) ;
You can’t perform that action at this time.
0 commit comments