From 86fde18b7d0501609407936c6b64fc43c680e2a3 Mon Sep 17 00:00:00 2001 From: Vyrtsev Mikhail Date: Thu, 17 Jan 2019 00:06:04 +0300 Subject: [PATCH] hide edit input if original text and edited are same --- web/app/components/input/input.jsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/app/components/input/input.jsx b/web/app/components/input/input.jsx index 6c9621c6..56f3d817 100644 --- a/web/app/components/input/input.jsx +++ b/web/app/components/input/input.jsx @@ -74,6 +74,11 @@ export default class Input extends Component { if (!text || !text.trim()) return; + if (text === this.props.value) { + this.props.onCancel && this.props.onCancel(); + this.setState({ preview: null, text: '' }); + } + this.setState({ isDisabled: true, isErrorShown: false }); const request = @@ -83,10 +88,7 @@ export default class Input extends Component { request .then(comment => { - if (this.props.onSubmit) { - this.props.onSubmit(comment); - } - + this.props.onSubmit && this.props.onSubmit(comment); this.setState({ preview: null, text: '' }); }) .catch(e => {