Skip to content

Commit

Permalink
fix: set date to undefined if a part is cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Feb 9, 2025
1 parent e5f4cc0 commit 45909fb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/core/src/useDateTimeField/useTemporalStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export function useTemporalStore(init: TemporalValueStoreInit) {
);

watch(model.get, value => {
if (!value && isTemporalPartial(temporalVal.value)) {
return;
}

temporalVal.value = toZonedDateTime(value) ?? createTemporalPartial(toValue(init.calendar), toValue(init.timeZone));
});

Expand Down Expand Up @@ -91,9 +95,7 @@ export function useTemporalStore(init: TemporalValueStoreInit) {
get: () => temporalVal.value,
set: value => {
temporalVal.value = value;
if (!isTemporalPartial(value)) {
model.set?.(toDate(value));
}
model.set?.(isTemporalPartial(value) ? undefined : toDate(value));
},
});

Expand Down

0 comments on commit 45909fb

Please sign in to comment.