From 7cae4f4a902afe92090c2049fa09b6ecac9b23c7 Mon Sep 17 00:00:00 2001 From: schelv <13403863+schelv@users.noreply.github.com> Date: Sat, 2 Dec 2023 15:06:38 +0100 Subject: [PATCH] leave event value undefined --- src/components/ha-base-time-input.ts | 4 +--- src/components/ha-time-input.ts | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/ha-base-time-input.ts b/src/components/ha-base-time-input.ts index ec19ad400921..693e0f38faae 100644 --- a/src/components/ha-base-time-input.ts +++ b/src/components/ha-base-time-input.ts @@ -268,9 +268,7 @@ export class HaBaseTimeInput extends LitElement { } private _clearValue(): void { - fireEvent(this, "value-changed", { - value: null, - }); + fireEvent(this, "value-changed"); } private _valueChanged(ev: InputEvent) { diff --git a/src/components/ha-time-input.ts b/src/components/ha-time-input.ts index 908a5830efe5..5287ea51d0ec 100644 --- a/src/components/ha-time-input.ts +++ b/src/components/ha-time-input.ts @@ -56,17 +56,17 @@ export class HaTimeInput extends LitElement { `; } - private _timeChanged(ev: CustomEvent<{ value: TimeChangedEvent | null }>) { + private _timeChanged(ev: CustomEvent<{ value?: TimeChangedEvent }>) { ev.stopPropagation(); const eventValue = ev.detail.value; const useAMPM = useAmPm(this.locale); let value; - // An eventValue of null means the value is being cleared, - // and value will (intentionally) be left undefined. + // An undefined eventValue means the time selector is being cleared, + // the `value` variable will (intentionally) be left undefined. if ( - eventValue !== null && + eventValue !== undefined && (!isNaN(eventValue.hours) || !isNaN(eventValue.minutes) || !isNaN(eventValue.seconds))