Skip to content

Commit

Permalink
Default to first option if value isn’t in the options
Browse files Browse the repository at this point in the history
  • Loading branch information
tbleckert committed Jun 3, 2018
1 parent 3a59024 commit 0f1f2a3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,11 @@ function (_React$Component) {
labelClassName = "".concat(this.classes.search, " ").concat(_Bem.default.m(this.classes.search, 'placeholder'));
} else {
option = this.findByValue(this.state.defaultOptions, this.state.value);

if (!option) {
option = this.state.defaultOptions[0];
}

labelValue = option.name;
labelClassName = this.classes.search;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-select-search",
"version": "0.9.2",
"version": "0.9.3",
"description": "React powered selectbox with filter",
"main": "dist/index.js",
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@ class SelectSearch extends React.Component {
labelClassName = `${this.classes.search} ${Bem.m(this.classes.search, 'placeholder')}`;
} else {
option = this.findByValue(this.state.defaultOptions, this.state.value);

if (!option) {
option = this.state.defaultOptions[0];
}

labelValue = option.name;
labelClassName = this.classes.search;
}
Expand Down

0 comments on commit 0f1f2a3

Please sign in to comment.