From 2d209adf986fbbb22fc302bc0c1b65d04767be88 Mon Sep 17 00:00:00 2001 From: Konstantyn Maryanovsky Date: Mon, 30 Jan 2017 13:36:43 +0200 Subject: [PATCH 1/2] Fixed bug. Looking for focusedOption can return incorrect value in case when focusedOption not equal to any element of array --- src/Select.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Select.js b/src/Select.js index bfeefc7554..0396fb7660 100644 --- a/src/Select.js +++ b/src/Select.js @@ -1009,7 +1009,7 @@ const Select = React.createClass({ let focusedOption = this.state.focusedOption || selectedOption; if (focusedOption && !focusedOption.disabled) { - const focusedOptionIndex = options.indexOf(focusedOption); + const focusedOptionIndex = options.findIndex(option => option.value === focusedOption.value); if (focusedOptionIndex !== -1) { return focusedOptionIndex; } From a0972e3855a3766c426a83a220292af30a95cce9 Mon Sep 17 00:00:00 2001 From: Konstantyn Maryanovsky Date: Tue, 31 Jan 2017 20:17:17 +0200 Subject: [PATCH 2/2] Fixed bug. Looking for focusedOption can return incorrect value in case when focusedOption not equal to any element of array, IE compatible --- src/Select.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Select.js b/src/Select.js index 0396fb7660..3f18a524ff 100644 --- a/src/Select.js +++ b/src/Select.js @@ -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; }