Skip to content

Commit 45f5665

Browse files
committed
Fix selected option focus when valueKey is not "value"
1 parent 196c7bb commit 45f5665

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/Select.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,15 +1108,15 @@ var Select = (0, _createReactClass2['default'])({
11081108
});
11091109
},
11101110

1111-
getFocusableOptionIndex: function getFocusableOptionIndex(selectedOption) {
1111+
getFocusableOptionIndex: function getFocusableOptionIndex(selectedOption, valueKey) {
11121112
var options = this._visibleOptions;
11131113
if (!options.length) return null;
11141114

11151115
var focusedOption = this.state.focusedOption || selectedOption;
11161116
if (focusedOption && !focusedOption.disabled) {
11171117
var focusedOptionIndex = -1;
11181118
options.some(function (option, index) {
1119-
var isOptionEqual = option.value === focusedOption.value;
1119+
var isOptionEqual = option[valueKey] === focusedOption[valueKey];
11201120
if (isOptionEqual) {
11211121
focusedOptionIndex = index;
11221122
}
@@ -1166,7 +1166,7 @@ var Select = (0, _createReactClass2['default'])({
11661166
var options = this._visibleOptions = this.filterOptions(this.props.multi ? this.getValueArray(this.props.value) : null);
11671167
var isOpen = this.state.isOpen;
11681168
if (this.props.multi && !options.length && valueArray.length && !this.state.inputValue) isOpen = false;
1169-
var focusedOptionIndex = this.getFocusableOptionIndex(valueArray[0]);
1169+
var focusedOptionIndex = this.getFocusableOptionIndex(valueArray[0], this.props.valueKey);
11701170

11711171
var focusedOption = null;
11721172
if (focusedOptionIndex !== null) {
@@ -1235,4 +1235,4 @@ var Select = (0, _createReactClass2['default'])({
12351235
});
12361236

12371237
exports['default'] = Select;
1238-
module.exports = exports['default'];
1238+
module.exports = exports['default'];

0 commit comments

Comments
 (0)