Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
Fixed issue with selectedOption running on non-select fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jamgregory committed Jun 17, 2020
1 parent acab03c commit f31ddff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
12 changes: 8 additions & 4 deletions dist/editable.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,14 @@ var Editable = /*#__PURE__*/function (_React$Component) {
if (this.props.disabled) {
p = value;
} else {
var selectedOption = this.props.options.filter(function (option) {
return option.value === value;
});
a = this.props.type === "select" ? selectedOption[0].label : value;
if (this.props.type === "select") {
var selectedOption = this.props.options.filter(function (option) {
return option.value === value;
});
a = selectedOption[0].label;
} else {
a = value;
}
}
} else {
p = value;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"edit",
"ajax"
],
"version": "0.6.5-2",
"version": "0.6.5-3",
"main": "dist/editable.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
8 changes: 6 additions & 2 deletions src/Editable.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,12 @@ export default class Editable extends React.Component{
if(this.props.disabled){
p = value
}else{
const selectedOption = this.props.options.filter((option) => { return option.value === value });
a = (this.props.type === "select" ? selectedOption[0].label : value)
if (this.props.type === "select"){
const selectedOption = this.props.options.filter((option) => { return option.value === value });
a = selectedOption[0].label
} else {
a = value
}
}
}else{
p = value
Expand Down

0 comments on commit f31ddff

Please sign in to comment.