@@ -48,7 +48,6 @@ class Dropdown extends React.Component {
48
48
this . state = { } ;
49
49
50
50
this . lastOpenEventType = null ;
51
- this . isKeyboardClick = false ;
52
51
}
53
52
54
53
componentDidMount ( ) {
@@ -83,7 +82,7 @@ class Dropdown extends React.Component {
83
82
let children = this . extractChildren ( ) ;
84
83
let Component = this . props . componentClass ;
85
84
86
- let props = omit ( this . props , [ 'id' ] ) ;
85
+ let props = omit ( this . props , [ 'id' , 'role' ] ) ;
87
86
88
87
const rootClasses = {
89
88
open : this . props . open ,
@@ -120,8 +119,7 @@ class Dropdown extends React.Component {
120
119
return ;
121
120
}
122
121
123
- this . toggleOpen ( this . isKeyboardClick ? 'keydown' : 'click' ) ;
124
- this . isKeyboardClick = false ;
122
+ this . toggleOpen ( 'click' ) ;
125
123
}
126
124
127
125
handleKeyDown ( event ) {
@@ -142,10 +140,6 @@ class Dropdown extends React.Component {
142
140
case keycode . codes . tab :
143
141
this . handleClose ( event ) ;
144
142
break ;
145
- case keycode . codes . space :
146
- case keycode . codes . enter :
147
- this . isKeyboardClick = true ;
148
- break ;
149
143
default :
150
144
}
151
145
}
@@ -166,7 +160,7 @@ class Dropdown extends React.Component {
166
160
167
161
if (
168
162
this . lastOpenEventType === 'keydown' ||
169
- this . props . alwaysFocusNextOnOpen
163
+ this . props . role === 'menuitem'
170
164
) {
171
165
menu . focusNext ( ) ;
172
166
}
@@ -227,7 +221,8 @@ class Dropdown extends React.Component {
227
221
let toggleProps = {
228
222
open,
229
223
id : this . props . id ,
230
- ref : TOGGLE_REF
224
+ ref : TOGGLE_REF ,
225
+ role : this . props . role
231
226
} ;
232
227
233
228
toggleProps . onClick = createChainedFunction (
@@ -327,9 +322,10 @@ Dropdown.propTypes = {
327
322
onSelect : React . PropTypes . func ,
328
323
329
324
/**
330
- * Focus first menu item on menu open on all events, not just keydown events.
325
+ * If `'menuitem'`, causes the dropdown to behave like a menu item rather than
326
+ * a menu button.
331
327
*/
332
- alwaysFocusNextOnOpen : React . PropTypes . bool
328
+ role : React . PropTypes . string
333
329
} ;
334
330
335
331
Dropdown = uncontrollable ( Dropdown , { open : 'onToggle' } ) ;
0 commit comments