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({
248248 return ;
249249 }
250250
251+ if ( ! menuRef . current && key === 'Tab' ) {
252+ return ;
253+ }
254+
251255 lastSourceEvent . current = event . type ;
252256
253257 switch ( key ) {
Original file line number Diff line number Diff line change @@ -335,6 +335,26 @@ describe('<Dropdown>', () => {
335335 } ) ;
336336 } ) ;
337337
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+
338358 describe ( 'popper config' , ( ) => {
339359 it ( 'can add modifiers' , ( done ) => {
340360 const spy = sinon . spy ( ) ;
You can’t perform that action at this time.
0 commit comments