Skip to content

Commit

Permalink
Re-added the focus() method on Select.Async
Browse files Browse the repository at this point in the history
  • Loading branch information
mcls committed Oct 28, 2016
1 parent dfe4119 commit ba2bd5e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Async.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ export default class Async extends Component {
return searchPromptText;
}

focus () {
this.select.focus();
}

render () {
const { children, loadingPlaceholder, placeholder } = this.props;
const { isLoading, options } = this.state;
Expand Down
13 changes: 13 additions & 0 deletions test/Async-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,4 +434,17 @@ describe('Async', () => {
return expect(onInputChange, 'was called times', 1);
});
});

describe('.focus()', () => {
beforeEach(() => {
createControl({});
});

it('focuses the search input', () => {
var input = asyncNode.querySelector('input');
expect(input, 'not to equal', document.activeElement);
asyncInstance.focus();
expect(input, 'to equal', document.activeElement);
});
});
});

0 comments on commit ba2bd5e

Please sign in to comment.