diff --git a/src/Creatable.js b/src/Creatable.js index 145c568aa3..f1f3fe33e5 100644 --- a/src/Creatable.js +++ b/src/Creatable.js @@ -203,6 +203,10 @@ const Creatable = React.createClass({ } }, + focus () { + this.select.focus(); + }, + render () { const { newOptionCreator, diff --git a/test/Creatable-test.js b/test/Creatable-test.js index 968478fd9a..45014c105a 100644 --- a/test/Creatable-test.js +++ b/test/Creatable-test.js @@ -237,4 +237,17 @@ describe('Creatable', () => { createControl({ onInputKeyDown: event => done() }); return creatableInstance.onInputKeyDown({ keyCode: 97 }); }); + + describe('.focus()', () => { + beforeEach(() => { + createControl({}); + TestUtils.Simulate.blur(filterInputNode); + }); + + it('focuses the search input', () => { + expect(filterInputNode, 'not to equal', document.activeElement); + creatableInstance.focus(); + expect(filterInputNode, 'to equal', document.activeElement); + }); + }); });