Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/panels/config/helpers/forms/ha-counter-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class HaCounterForm extends LitElement {
if (item) {
this._name = item.name || "";
this._icon = item.icon || "";
this._maximum = item.maximum;
this._minimum = item.minimum;
this._maximum = item.maximum ?? undefined;
this._minimum = item.minimum ?? undefined;
Comment on lines +47 to +48
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? If it is undefined, we set it to undefined?

Copy link
Copy Markdown
Member Author

@spacegaier spacegaier Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It comes in as "NaN" but that results in a "0" in the input field. With "undefined" the input stays empty as intended.

this._restore = item.restore ?? true;
this._step = item.step ?? 1;
this._initial = item.initial ?? 0;
Expand Down Expand Up @@ -163,7 +163,9 @@ class HaCounterForm extends LitElement {
const configValue = target.configValue;
const value =
target.type === "number"
? Number(ev.detail.value)
? ev.detail.value !== ""
? Number(ev.detail.value)
: undefined
: target.localName === "ha-switch"
? (ev.target as HaSwitch).checked
: ev.detail.value;
Expand Down