Fix input number helper (#6988)

This commit is contained in:
Bram Kragten 2020-09-14 17:00:56 +02:00 committed by GitHub
parent 92ed14c0e4
commit 3030b8d476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,9 +6,9 @@ import {
CSSResult, CSSResult,
customElement, customElement,
html, html,
internalProperty,
LitElement, LitElement,
property, property,
internalProperty,
TemplateResult, TemplateResult,
} from "lit-element"; } from "lit-element";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -48,12 +48,12 @@ class HaInputNumberForm extends LitElement {
this._max = item.max ?? 100; this._max = item.max ?? 100;
this._min = item.min ?? 0; this._min = item.min ?? 0;
this._mode = item.mode || "slider"; this._mode = item.mode || "slider";
this._step = item.step || 1; this._step = item.step ?? 1;
this._unit_of_measurement = item.unit_of_measurement; this._unit_of_measurement = item.unit_of_measurement;
} else { } else {
this._item = { this._item = {
min: 0, min: 0,
max: 0, max: 100,
}; };
this._name = ""; this._name = "";
this._icon = ""; this._icon = "";
@ -176,8 +176,10 @@ class HaInputNumberForm extends LitElement {
return; return;
} }
ev.stopPropagation(); ev.stopPropagation();
const configValue = (ev.target as any).configValue; const target = ev.target as any;
const value = ev.detail.value; const configValue = target.configValue;
const value =
target.type === "number" ? Number(ev.detail.value) : ev.detail.value;
if (this[`_${configValue}`] === value) { if (this[`_${configValue}`] === value) {
return; return;
} }