Only add milliseconds when enabled or if it has a value (#10842)

This commit is contained in:
Bram Kragten 2021-12-09 22:38:03 +01:00 committed by GitHub
parent ead5e288eb
commit 919bf94a03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,14 +122,20 @@ class HaDurationInput extends LitElement {
value %= 60; value %= 60;
} }
fireEvent(this, "value-changed", { const newValue: HaDurationData = {
value: {
hours, hours,
minutes, minutes,
seconds: this._seconds, seconds: this._seconds,
milliseconds: this._milliseconds, };
...{ [unit]: value },
}, if (this.enableMillisecond || this._milliseconds) {
newValue.milliseconds = this._milliseconds;
}
newValue[unit] = value;
fireEvent(this, "value-changed", {
value: newValue,
}); });
} }
} }