Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Select = React.createClass({
addLabelText: React.PropTypes.string, // placeholder displayed when you want to add a label on a multi-value input
'aria-label': React.PropTypes.string, // Aria label (for assistive tech)
'aria-labelledby': React.PropTypes.string, // HTML ID of an element that should be used as the label (for assistive tech)
arrowRenderer: React.PropTypes.func, // Create drop-down caret element
arrowRenderer: React.PropTypes.func, // Create drop-down caret element
autoBlur: React.PropTypes.bool, // automatically blur the component when an option is selected
autofocus: React.PropTypes.bool, // autofocus the component on mount
autosize: React.PropTypes.bool, // whether to enable autosizing or not
Expand Down Expand Up @@ -916,6 +916,12 @@ const Select = React.createClass({
}
},

onOptionRef(ref, isFocused) {
if (isFocused) {
this.focused = ref;
}
},

renderMenu (options, valueArray, focusedOption) {
if (options && options.length) {
return this.props.menuRenderer({
Expand All @@ -932,6 +938,7 @@ const Select = React.createClass({
selectValue: this.selectValue,
valueArray,
valueKey: this.props.valueKey,
onOptionRef: this.onOptionRef,
});
} else if (this.props.noResultsText) {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/utils/defaultMenuRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ function menuRenderer ({
options,
valueArray,
valueKey,
onOptionRef
}) {
let Option = optionComponent;

return options.map((option, i) => {
let isSelected = valueArray && valueArray.indexOf(option) > -1;
let isFocused = option === focusedOption;
let optionRef = isFocused ? 'focused' : null;
let optionClass = classNames(optionClassName, {
'Select-option': true,
'is-selected': isSelected,
Expand All @@ -39,7 +39,7 @@ function menuRenderer ({
onSelect={onSelect}
option={option}
optionIndex={i}
ref={optionRef}
ref={ref => { onOptionRef(ref, isFocused); }}
>
{optionRenderer(option, i)}
</Option>
Expand Down