@@ -248,6 +248,8 @@ export interface Props<
248
248
openMenuOnFocus : boolean ;
249
249
/** Allows control of whether the menu is opened when the Select is clicked */
250
250
openMenuOnClick : boolean ;
251
+ /** Allows control of whether the menu is opened on up and down arrows */
252
+ openMenuOnArrows : boolean ;
251
253
/** Array of options that populate the select menu */
252
254
options : OptionsOrGroups < Option , Group > ;
253
255
/** Number of options to jump in menu when page{up|down} keys are used */
@@ -310,6 +312,7 @@ export const defaultProps = {
310
312
noOptionsMessage : ( ) => 'No options' ,
311
313
openMenuOnFocus : false ,
312
314
openMenuOnClick : true ,
315
+ openMenuOnArrows : true ,
313
316
options : [ ] ,
314
317
pageSize : 5 ,
315
318
placeholder : 'Select...' ,
@@ -1565,6 +1568,7 @@ export default class Select<
1565
1568
onKeyDown,
1566
1569
tabSelectsValue,
1567
1570
openMenuOnFocus,
1571
+ openMenuOnArrows,
1568
1572
} = this . props ;
1569
1573
const { focusedOption, focusedValue, selectValue } = this . state ;
1570
1574
@@ -1657,15 +1661,20 @@ export default class Select<
1657
1661
this . selectOption ( focusedOption ) ;
1658
1662
break ;
1659
1663
case 'ArrowUp' :
1664
+ console . log ( 'up' , menuIsOpen ) ;
1660
1665
if ( menuIsOpen ) {
1661
1666
this . focusOption ( 'up' ) ;
1667
+ } else if ( ! openMenuOnArrows ) {
1668
+ return ;
1662
1669
} else {
1663
1670
this . openMenu ( 'last' ) ;
1664
1671
}
1665
1672
break ;
1666
1673
case 'ArrowDown' :
1667
1674
if ( menuIsOpen ) {
1668
1675
this . focusOption ( 'down' ) ;
1676
+ } else if ( ! openMenuOnArrows ) {
1677
+ return ;
1669
1678
} else {
1670
1679
this . openMenu ( 'first' ) ;
1671
1680
}
0 commit comments