Skip to content

Commit

Permalink
Store input on the instance rather than refs
Browse files Browse the repository at this point in the history
  • Loading branch information
moroshko committed Jul 20, 2016
1 parent bd7f284 commit 6b74a99
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Autowhatever.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default class Autowhatever extends Component {
super(props);

this.onKeyDown = this.onKeyDown.bind(this);
this.storeInputReference = this.storeInputReference.bind(this);
this.storeItemsContainerReference = this.storeItemsContainerReference.bind(this);
this.storeFocusedItemReference = this.storeFocusedItemReference.bind(this);
}
Expand All @@ -68,6 +69,12 @@ export default class Autowhatever extends Component {
this.ensureFocusedSuggestionIsVisible();
}

storeInputReference(input) {
if (input !== null) {
this.input = input;
}
}

storeItemsContainerReference(itemsContainer) {
if (itemsContainer !== null) {
this.itemsContainer = itemsContainer;
Expand Down Expand Up @@ -259,14 +266,14 @@ export default class Autowhatever extends Component {
value: '',
autoComplete: 'off',
role: 'combobox',
ref: 'input',
'aria-autocomplete': 'list',
'aria-owns': this.getItemsContainerId(),
'aria-expanded': isOpen,
'aria-activedescendant': ariaActivedescendant,
...theme(`react-autowhatever-${id}-input`, 'input'),
...this.props.inputProps,
onKeyDown: this.props.inputProps.onKeyDown && this.onKeyDown
onKeyDown: this.props.inputProps.onKeyDown && this.onKeyDown,
ref: this.storeInputReference
};

return (
Expand Down

0 comments on commit 6b74a99

Please sign in to comment.