Skip to content

Commit

Permalink
leave event value undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
schelv committed Dec 17, 2023
1 parent 1cf2957 commit 45845b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/components/ha-base-time-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/components/ha-time-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 45845b4

Please sign in to comment.