Skip to content

Commit

Permalink
Fixed bug. Looking for focusedOption can return incorrect value in ca…
Browse files Browse the repository at this point in the history
…se when focusedOption not equal to any element of array, IE compatible
  • Loading branch information
Konstantyn Maryanovsky committed Jan 31, 2017
1 parent 2d209ad commit a0972e3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Select.js
Expand Up @@ -1009,7 +1009,14 @@ const Select = React.createClass({

let focusedOption = this.state.focusedOption || selectedOption;
if (focusedOption && !focusedOption.disabled) {
const focusedOptionIndex = options.findIndex(option => option.value === focusedOption.value);
let focusedOptionIndex = -1;
options.some((option, index) => {
const isOptionEqual = option.value === focusedOption.value;
if (isOptionEqual) {
focusedOptionIndex = index;
}
return isOptionEqual;
});
if (focusedOptionIndex !== -1) {
return focusedOptionIndex;
}
Expand Down

0 comments on commit a0972e3

Please sign in to comment.