From ba2bd5e822e2ae2d53f73ea0a748b5b9166e8c82 Mon Sep 17 00:00:00 2001 From: Maarten Claes Date: Thu, 27 Oct 2016 13:38:37 +0200 Subject: [PATCH] Re-added the focus() method on Select.Async --- src/Async.js | 4 ++++ test/Async-test.js | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/Async.js b/src/Async.js index 17e949db0d..411a7eacd2 100644 --- a/src/Async.js +++ b/src/Async.js @@ -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; diff --git a/test/Async-test.js b/test/Async-test.js index c49e60b5ba..8742e315ff 100644 --- a/test/Async-test.js +++ b/test/Async-test.js @@ -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); + }); + }); });