From 73b3262491a0d4615b4a0203b7fbcfb1ec579604 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Mon, 2 Dec 2019 20:08:38 +0100 Subject: [PATCH] Fix editing delay action (#4309) --- src/panels/config/js/script/delay.tsx | 18 +++++++++++++++--- src/panels/config/js/script/wait.tsx | 3 +++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/panels/config/js/script/delay.tsx b/src/panels/config/js/script/delay.tsx index da78c3b809..3f1d69da80 100644 --- a/src/panels/config/js/script/delay.tsx +++ b/src/panels/config/js/script/delay.tsx @@ -1,14 +1,12 @@ import { h } from "preact"; import "@polymer/paper-input/paper-input"; -import { onChangeEvent } from "../../../../common/preact/event"; import { AutomationComponent } from "../automation-component"; export default class DelayAction extends AutomationComponent { - private onChange: (obj: any) => void; constructor() { super(); - this.onChange = onChangeEvent.bind(this, "action"); + this.onChange = this.onChange.bind(this); } public render({ action, localize }) { @@ -26,6 +24,20 @@ export default class DelayAction extends AutomationComponent { ); } + + private onChange(ev) { + if ( + !this.initialized || + ev.target.value === this.props.action[ev.target.name] + ) { + return; + } + + this.props.onChange(this.props.index, { + ...this.props.action, + [ev.target.name]: ev.target.value, + }); + } } (DelayAction as any).defaultConfig = { diff --git a/src/panels/config/js/script/wait.tsx b/src/panels/config/js/script/wait.tsx index 365d90c8ed..d9692f6cac 100644 --- a/src/panels/config/js/script/wait.tsx +++ b/src/panels/config/js/script/wait.tsx @@ -18,6 +18,9 @@ export default class WaitAction extends AutomationComponent { // Gets fired on mount. If empty, onChangeEvent removes attribute. // Without the attribute this action is no longer matched to this component. public onTemplateChange(ev) { + if (!this.initialized) { + return; + } this.props.onChange(this.props.index, { ...this.props.action, [ev.target.getAttribute("name")]: ev.target.value,