Skip to content

Commit

Permalink
Merge pull request JedWatson#1257 from jooj123/patch/add-back-on-inpu…
Browse files Browse the repository at this point in the history
…t-change

Add back onInputChange
  • Loading branch information
JedWatson authored Oct 5, 2016
2 parents b3db918 + ac6cb94 commit e99ab1f
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 @@ -22,6 +22,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 @@ -121,7 +122,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 @@ -131,6 +132,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 e99ab1f

Please sign in to comment.