Skip to content

Commit

Permalink
Add back onInputChange
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Jujou committed Sep 28, 2016
1 parent 962f138 commit ac6cb94
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Async.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const propTypes = {
React.PropTypes.string,
React.PropTypes.node
]),
onInputChange: React.PropTypes.func, // optional for keeping track of what is being typed
};

const defaultProps = {
Expand Down Expand Up @@ -118,7 +119,7 @@ export default class Async extends Component {
}

_onInputChange (inputValue) {
const { ignoreAccents, ignoreCase } = this.props;
const { ignoreAccents, ignoreCase, onInputChange } = this.props;

if (ignoreAccents) {
inputValue = stripDiacritics(inputValue);
Expand All @@ -128,6 +129,10 @@ export default class Async extends Component {
inputValue = inputValue.toLowerCase();
}

if (onInputChange) {
onInputChange(inputValue);
}

return this.loadOptions(inputValue);
}

Expand Down
11 changes: 11 additions & 0 deletions test/Async-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,15 @@ describe('Async', () => {
expect(asyncNode.className, 'to contain', 'Select');
});
});

describe('with onInputChange', () => {
it('should call onInputChange', () => {
const onInputChange = sinon.stub();
createControl({
onInputChange,
});
typeSearchText('a');
return expect(onInputChange, 'was called times', 1);
});
});
});

0 comments on commit ac6cb94

Please sign in to comment.