Skip to content

Commit fb8df1f

Browse files
committed
fix: Reset start time on value clear (fixes #1048)
1 parent aa9f0cf commit fb8df1f

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

src/VueDatePicker/VueDatePicker.vue

+1
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@
343343
const clearValue = (): void => {
344344
inputValue.value = '';
345345
clearInternalValues();
346+
dpMenuRef.value?.onValueCleared();
346347
inputRef.value?.setParsedDate(null);
347348
emit('update:model-value', null);
348349
emit('update:model-timezone-value', null);

src/VueDatePicker/components/DatePicker/DatePicker.vue

+2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
selectCurrentDate,
151151
updateTime,
152152
assignMonthAndYear,
153+
setStartTime,
153154
} = useDatePicker(props, emit, triggerCalendarTransition, updateFlowStep);
154155
const slots = useSlots();
155156
const { setHoverDate, getDayClassData, clearHoverDate } = useCalendarClass(modelValue, props);
@@ -303,5 +304,6 @@
303304
changeMonth,
304305
changeYear,
305306
selectWeekDate,
307+
setStartTime,
306308
});
307309
</script>

src/VueDatePicker/components/DatePicker/date-picker.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const useDatePicker = (
6363
const { validateMonthYearInRange, isDisabled, isDateRangeAllowed, checkMinMaxRange } = useValidation(props);
6464
const { updateTimeValues, getSetDateTime, setTime, assignStartTime, validateTime, disabledTimesConfig } =
6565
useTimePickerUtils(props, time, modelValue, updateFlow);
66+
6667
// Get month based on the calendar instance
6768
const month = computed(
6869
() =>
@@ -104,13 +105,17 @@ export const useDatePicker = (
104105
}
105106
};
106107

108+
const setStartTime = () => {
109+
if (defaultedStartTime.value) {
110+
assignStartTime(defaultedStartTime.value);
111+
}
112+
};
113+
107114
onMounted(() => {
108115
if (!props.shadow) {
109116
if (!modelValue.value) {
110117
setStartDate();
111-
if (defaultedStartTime.value) {
112-
assignStartTime(defaultedStartTime.value);
113-
}
118+
setStartTime();
114119
}
115120
mapInternalModuleValues(true);
116121
if (props.focusStartDate && props.startDate) {
@@ -675,5 +680,6 @@ export const useDatePicker = (
675680
selectCurrentDate,
676681
updateTime,
677682
assignMonthAndYear,
683+
setStartTime,
678684
};
679685
};

src/VueDatePicker/components/DatepickerMenu.vue

+5
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,14 @@
434434
}
435435
};
436436
437+
const onValueCleared = () => {
438+
dynCmpRef.value?.setStartTime?.();
439+
};
440+
437441
defineExpose({
438442
updateMonthYear,
439443
switchView,
440444
handleFlow,
445+
onValueCleared,
441446
});
442447
</script>

0 commit comments

Comments
 (0)