diff --git a/src/Select.js b/src/Select.js index 79d3903628..dc24d8d22a 100644 --- a/src/Select.js +++ b/src/Select.js @@ -311,6 +311,7 @@ const Select = React.createClass({ handleInputBlur (event) { if (this.refs.menu && document.activeElement.isEqualNode(this.refs.menu)) { + this.focus(); return; } diff --git a/test/Select-test.js b/test/Select-test.js index 002db59922..233bc2115f 100644 --- a/test/Select-test.js +++ b/test/Select-test.js @@ -2252,6 +2252,31 @@ describe('Select', () => { TestUtils.Simulate.blur(searchInputNode); expect(onBlur, 'was called once'); }); + + it( 'should focus on the input when the menu is active', () => { + instance = createControl({ + options: defaultOptions + }); + + clickArrowToOpen(); + instance.refs.menu.focus(); + + var inputFocus = sinon.spy( instance.refs.input, "focus" ); + instance.handleInputBlur(); + + expect( instance.refs.input.focus, 'was called once' ); + } ); + + it( 'should not focus the input when menu is not active', () => { + instance = createControl({ + options: defaultOptions + }); + + var inputFocus = sinon.spy( instance.refs.input, "focus" ); + instance.handleInputBlur(); + + expect( instance.refs.input.focus, 'was not called' ); + } ); }); describe('with onBlurResetsInput=true', () => {