Skip to content

Commit

Permalink
fix: Reset start time on value clear (fixes #1048)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasenkoo committed Jan 4, 2025
1 parent aa9f0cf commit fb8df1f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/VueDatePicker/VueDatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@
const clearValue = (): void => {
inputValue.value = '';
clearInternalValues();
dpMenuRef.value?.onValueCleared();
inputRef.value?.setParsedDate(null);
emit('update:model-value', null);
emit('update:model-timezone-value', null);
Expand Down
2 changes: 2 additions & 0 deletions src/VueDatePicker/components/DatePicker/DatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
selectCurrentDate,
updateTime,
assignMonthAndYear,
setStartTime,
} = useDatePicker(props, emit, triggerCalendarTransition, updateFlowStep);
const slots = useSlots();
const { setHoverDate, getDayClassData, clearHoverDate } = useCalendarClass(modelValue, props);
Expand Down Expand Up @@ -303,5 +304,6 @@
changeMonth,
changeYear,
selectWeekDate,
setStartTime,
});
</script>
12 changes: 9 additions & 3 deletions src/VueDatePicker/components/DatePicker/date-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const useDatePicker = (
const { validateMonthYearInRange, isDisabled, isDateRangeAllowed, checkMinMaxRange } = useValidation(props);
const { updateTimeValues, getSetDateTime, setTime, assignStartTime, validateTime, disabledTimesConfig } =
useTimePickerUtils(props, time, modelValue, updateFlow);

// Get month based on the calendar instance
const month = computed(
() =>
Expand Down Expand Up @@ -104,13 +105,17 @@ export const useDatePicker = (
}
};

const setStartTime = () => {
if (defaultedStartTime.value) {
assignStartTime(defaultedStartTime.value);
}
};

onMounted(() => {
if (!props.shadow) {
if (!modelValue.value) {
setStartDate();
if (defaultedStartTime.value) {
assignStartTime(defaultedStartTime.value);
}
setStartTime();
}
mapInternalModuleValues(true);
if (props.focusStartDate && props.startDate) {
Expand Down Expand Up @@ -675,5 +680,6 @@ export const useDatePicker = (
selectCurrentDate,
updateTime,
assignMonthAndYear,
setStartTime,
};
};
5 changes: 5 additions & 0 deletions src/VueDatePicker/components/DatepickerMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,14 @@
}
};
const onValueCleared = () => {
dynCmpRef.value?.setStartTime?.();
};
defineExpose({
updateMonthYear,
switchView,
handleFlow,
onValueCleared,
});
</script>

0 comments on commit fb8df1f

Please sign in to comment.