Skip to content

Commit

Permalink
Merge pull request #1952 from davidroeca/onSelectResetsInput
Browse files Browse the repository at this point in the history
Resolve #709
  • Loading branch information
JedWatson committed Sep 9, 2017
2 parents a288be7 + a20543f commit ed1c7cf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Select.js
Expand Up @@ -516,8 +516,9 @@ class Select extends React.Component {
//NOTE: update value in the callback to make sure the input value is empty so that there are no styling issues (Chrome had issue otherwise)
this.hasScrolledToOption = false;
if (this.props.multi) {
const updatedValue = this.props.onSelectResetsInput ? '' : this.state.inputValue;
this.setState({
inputValue: this.handleInputValueChange(''),
inputValue: this.handleInputValueChange(updatedValue),
focusedIndex: null
}, () => {
this.addValue(value);
Expand Down Expand Up @@ -1090,6 +1091,7 @@ Select.propTypes = {
onInputKeyDown: PropTypes.func, // input keyDown handler: function (event) {}
onMenuScrollToBottom: PropTypes.func, // fires when the menu is scrolled to the bottom; can be used to paginate options
onOpen: PropTypes.func, // fires when the menu is opened
onSelectResetsInput: PropTypes.bool, // whether input is cleared on select (works only for multiselect)
onValueClick: PropTypes.func, // onClick handler for value labels: function (value, event) {}
openAfterFocus: PropTypes.bool, // boolean to enable opening dropdown when focused
openOnFocus: PropTypes.bool, // always open options menu on focus
Expand Down Expand Up @@ -1142,6 +1144,7 @@ Select.defaultProps = {
multi: false,
noResultsText: 'No results found',
onBlurResetsInput: true,
onSelectResetsInput: true,
onCloseResetsInput: true,
optionComponent: Option,
pageSize: 5,
Expand Down

0 comments on commit ed1c7cf

Please sign in to comment.