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 Oct 23, 2023
1 parent 9a33cbb commit d6ca39c
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 d6ca39c

Please sign in to comment.