From b64087b187f21e2019229eb3f8c97600c130a2d7 Mon Sep 17 00:00:00 2001 From: James Gregory-Monk Date: Wed, 17 Jun 2020 16:33:20 +0100 Subject: [PATCH] Fixed issue with `selectedOption` running on non-select fields --- package.json | 2 +- src/Editable.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index bc34f38..6f9ee7d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/Editable.js b/src/Editable.js index 54aa6e3..ab6cd13 100644 --- a/src/Editable.js +++ b/src/Editable.js @@ -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