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;
}
const newValue: HaDurationData = {
hours,
minutes,
seconds: this._seconds,
};
if (this.enableMillisecond || this._milliseconds) {
newValue.milliseconds = this._milliseconds;
}
newValue[unit] = value;
fireEvent(this, "value-changed", {
value: {
hours,
minutes,
seconds: this._seconds,
milliseconds: this._milliseconds,
...{ [unit]: value },
},
value: newValue,
});
}
}