Skip to content

Commit

Permalink
Required was not being updated without an onChange handler
Browse files Browse the repository at this point in the history
  • Loading branch information
JedWatson committed Sep 12, 2017
1 parent 8adf585 commit a13b144
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* changed; by default, the menu for multi-selects now closes when an option is selected
* fixed; `Async` component always called `onChange` even when it wasn't provided
* fixed; input lag for the `Async` component when results are returned from cache
* fixed; required was not being updated without an onChange handler

## v1.0.0-rc.8 / 2017-09-12

Expand Down
9 changes: 5 additions & 4 deletions src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,15 +496,16 @@ class Select extends React.Component {
if (this.props.autoBlur) {
this.blurInput();
}
if (!this.props.onChange) return;
if (this.props.required) {
const required = this.handleRequired(value, this.props.multi);
this.setState({ required });
}
if (this.props.simpleValue && value) {
value = this.props.multi ? value.map(i => i[this.props.valueKey]).join(this.props.delimiter) : value[this.props.valueKey];
if (this.props.onChange) {
if (this.props.simpleValue && value) {
value = this.props.multi ? value.map(i => i[this.props.valueKey]).join(this.props.delimiter) : value[this.props.valueKey];
}
this.props.onChange(value);
}
this.props.onChange(value);
}

selectValue (value) {
Expand Down

0 comments on commit a13b144

Please sign in to comment.