From 92032be5d70e1571bc5c85ff7b049dd376b92374 Mon Sep 17 00:00:00 2001 From: Pierre-Gilles Leymarie Date: Mon, 6 Sep 2021 09:46:47 +0800 Subject: [PATCH] In scene, trigger device state change should parse number as float --- .../scene/edit-scene/triggers/DeviceFeatureState.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx b/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx index da36e5c264..78a1832604 100644 --- a/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx +++ b/front/src/routes/scene/edit-scene/triggers/DeviceFeatureState.jsx @@ -36,7 +36,12 @@ class TurnOnLight extends Component { if (value.includes(',')) { value = value.replaceAll(',', '.'); } - this.props.updateTriggerProperty(this.props.index, 'value', value); + const lastCharacter = value.length > 0 ? value[value.length - 1] : ''; + if (!isNaN(parseFloat(e.target.value)) && lastCharacter !== '.') { + this.props.updateTriggerProperty(this.props.index, 'value', parseFloat(value)); + } else { + this.props.updateTriggerProperty(this.props.index, 'value', value); + } }; handleValueChangeBinary = newValue => () => { this.props.updateTriggerProperty(this.props.index, 'value', newValue);