diff --git a/src/Select.js b/src/Select.js index 0e955cd7ea..46f8977e07 100644 --- a/src/Select.js +++ b/src/Select.js @@ -565,7 +565,6 @@ class Select extends React.Component { this.hasScrolledToOption = false; } const updatedValue = this.props.onSelectResetsInput ? '' : this.state.inputValue; - console.log(this.props.onSelectResetsInput, this.state.inputValue, updatedValue); if (this.props.multi) { this.setState({ focusedIndex: null, diff --git a/test/Select-test.js b/test/Select-test.js index d0cb508e07..2fc273ce40 100644 --- a/test/Select-test.js +++ b/test/Select-test.js @@ -2129,6 +2129,66 @@ describe('Select', () => { }); + describe('with multi=true and onSelectResetsInput=false', () => { + it('should have retained inputValue after accepting selection', () => { + options = [ + { value: 'one', label: 'One' }, + { value: 'two', label: 'Two' }, + { value: 'three', label: 'Three' }, + { value: 'four', label: 'Four' } + ]; + + // Render an instance of the component + wrapper = createControlWithWrapper({ + value: '', + options: options, + multi: true, + closeOnSelect: false, + removeSelected: false, + onSelectResetsInput: false + }); + + instance.setState({ + isFocused: true + }); + + clickArrowToOpen(); + typeSearchText('two'); + pressEnterToAccept(); + setValueProp('two'); // trigger componentWillReceiveProps + + expect(instance.state.inputValue, 'to equal', 'two'); + }); + + it('should have reset the inputValue after accepting selection', () => { + options = [ + { value: 'one', label: 'One' }, + { value: 'two', label: 'Two' }, + { value: 'three', label: 'Three' }, + { value: 'four', label: 'Four' } + ]; + + // Render an instance of the component + wrapper = createControlWithWrapper({ + value: '', + options: options, + multi: true, + closeOnSelect: false, + removeSelected: false + }); + + instance.setState({ + isFocused: true + }); + + clickArrowToOpen(); + typeSearchText('two'); + pressEnterToAccept(); + + expect(instance.state.inputValue, 'to equal', ''); + }); + }); + describe('with removeSelected=false', () => { beforeEach(() => { options = [