Remove float value in float form when emptied (#9947)

This commit is contained in:
Bram Kragten 2021-09-03 20:07:22 +02:00 committed by GitHub
parent 61c8d23a7e
commit 8565a0d911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,17 +32,19 @@ export class HaFormFloat extends LitElement implements HaFormElement {
.autoValidate=${this.schema.required}
@value-changed=${this._valueChanged}
>
<span suffix="" slot="suffix">${this.suffix}</span>
<span suffix slot="suffix">${this.suffix}</span>
</paper-input>
`;
}
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;
}