Skip to content

Commit

Permalink
fix: date-time widget coercition
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianCataldo committed Nov 30, 2023
1 parent 0437105 commit de1f6a8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/shoelace/src/widgets/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ export const date: Widgets['date'] = (options) => html`
.id=${options.id}
.required=${options.required ?? false}
@sl-input=${(event: CustomEvent) => {
const { valueAsDate: newValue } = event.target as SlInput;
options.valueChangedCallback?.(newValue ?? undefined);
const { valueAsDate: newValue, value } = event.target as SlInput;
options.valueChangedCallback?.(
// NOTE: Date time does not return `valueAsDate`
newValue ?? value ? new Date(value) : undefined,
);
}}
>
</sl-input>
Expand Down

0 comments on commit de1f6a8

Please sign in to comment.