From 8565a0d91110bb35897ddb953f0c79ed7e35772c Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 3 Sep 2021 20:07:22 +0200 Subject: [PATCH] Remove float value in float form when emptied (#9947) --- src/components/ha-form/ha-form-float.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/ha-form/ha-form-float.ts b/src/components/ha-form/ha-form-float.ts index edf3c13576..698667eca4 100644 --- a/src/components/ha-form/ha-form-float.ts +++ b/src/components/ha-form/ha-form-float.ts @@ -32,17 +32,19 @@ export class HaFormFloat extends LitElement implements HaFormElement { .autoValidate=${this.schema.required} @value-changed=${this._valueChanged} > - ${this.suffix} + ${this.suffix} `; } private get _value() { - return this.data || 0; + return this.data; } private _valueChanged(ev: Event) { - const value = Number((ev.target as PaperInputElement).value); + const value: number | undefined = (ev.target as PaperInputElement).value + ? Number((ev.target as PaperInputElement).value) + : undefined; if (this._value === value) { return; }