Fix dark switch for map card editor (#3856)

This commit is contained in:
Bram Kragten 2019-10-02 21:26:48 +02:00 committed by GitHub
parent 391b2dcf6a
commit 3622514131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -161,31 +161,22 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
return; return;
} }
const target = ev.target! as EditorTarget; const target = ev.target! as EditorTarget;
if ( if (target.configValue && this[`_${target.configValue}`] === target.value) {
target.configValue &&
ev.detail &&
this[`_${target.configValue}`] === ev.detail.value
) {
return; return;
} }
if (target.configValue && ev.detail) { let value: any = target.value;
if (
ev.detail.value === "" ||
(target.type === "number" && isNaN(Number(ev.detail.value)))
) {
delete this._config[target.configValue!];
} else {
let value: any = ev.detail.value;
if (target.type === "number") { if (target.type === "number") {
value = Number(value); value = Number(value);
} }
if (target.value === "" || (target.type === "number" && isNaN(value))) {
delete this._config[target.configValue!];
} else if (target.configValue) {
this._config = { this._config = {
...this._config, ...this._config,
[target.configValue]: [target.configValue]:
target.checked !== undefined ? target.checked : value, target.checked !== undefined ? target.checked : value,
}; };
} }
}
fireEvent(this, "config-changed", { config: this._config }); fireEvent(this, "config-changed", { config: this._config });
} }