@@ -41,6 +41,7 @@ var propTypes = {
41
41
loadingPlaceholder : _react2 [ 'default' ] . PropTypes . oneOfType ( [ // replaces the placeholder while options are loading
42
42
_react2 [ 'default' ] . PropTypes . string , _react2 [ 'default' ] . PropTypes . node ] ) ,
43
43
loadOptions : _react2 [ 'default' ] . PropTypes . func . isRequired , // callback to load options asynchronously; (inputValue: string, callback: Function): ?Promise
44
+ multi : _react2 [ 'default' ] . PropTypes . bool , // multi-value input
44
45
options : _react . PropTypes . array . isRequired , // array of options
45
46
placeholder : _react2 [ 'default' ] . PropTypes . oneOfType ( [ // field placeholder, displayed when there's no value (shared with Select)
46
47
_react2 [ 'default' ] . PropTypes . string , _react2 [ 'default' ] . PropTypes . node ] ) ,
@@ -1161,6 +1162,10 @@ var Select = _react2['default'].createClass({
1161
1162
1162
1163
var valueArray = this . getValueArray ( nextProps . value , nextProps ) ;
1163
1164
1165
+ if ( ! nextProps . isOpen && this . props . isOpen ) {
1166
+ this . closeMenu ( ) ;
1167
+ }
1168
+
1164
1169
if ( nextProps . required ) {
1165
1170
this . setState ( {
1166
1171
required : this . handleRequired ( valueArray [ 0 ] , nextProps . multi )
@@ -1337,7 +1342,7 @@ var Select = _react2['default'].createClass({
1337
1342
} ) ;
1338
1343
} else {
1339
1344
// otherwise, focus the input and open the menu
1340
- this . _openAfterFocus = true ;
1345
+ this . _openAfterFocus = this . props . openOnFocus ;
1341
1346
this . focus ( ) ;
1342
1347
}
1343
1348
} ,
@@ -2113,7 +2118,14 @@ var Select = _react2['default'].createClass({
2113
2118
2114
2119
var focusedOption = this . state . focusedOption || selectedOption ;
2115
2120
if ( focusedOption && ! focusedOption . disabled ) {
2116
- var focusedOptionIndex = options . indexOf ( focusedOption ) ;
2121
+ var focusedOptionIndex = - 1 ;
2122
+ options . some ( function ( option , index ) {
2123
+ var isOptionEqual = option . value === focusedOption . value ;
2124
+ if ( isOptionEqual ) {
2125
+ focusedOptionIndex = index ;
2126
+ }
2127
+ return isOptionEqual ;
2128
+ } ) ;
2117
2129
if ( focusedOptionIndex !== - 1 ) {
2118
2130
return focusedOptionIndex ;
2119
2131
}
0 commit comments