diff --git a/src/datepicker/Timepicker.vue b/src/datepicker/Timepicker.vue
index dc13a34..ec9ea9e 100644
--- a/src/datepicker/Timepicker.vue
+++ b/src/datepicker/Timepicker.vue
@@ -15,7 +15,7 @@
:ref="item.ref"
:class="{ selected: item.selected }"
:disabled="!isEnabled(item.date)"
- @click="hours=item.value"
+ @click.stop.prevent="hours=item.value"
>
{{padStartZero(item.value)}}
@@ -27,7 +27,7 @@
:ref="item.ref"
:class="{ selected: item.selected }"
:disabled="!isEnabled(item.date)"
- @click="selectMinutes(item)"
+ @click.stop.prevent="selectMinutes(item)"
>
{{padStartZero(item.value)}}
@@ -109,6 +109,19 @@ export default defineComponent({
const hours = ref(currentDate.value.getHours())
const minutes = ref(currentDate.value.getMinutes())
+ watch(() => props.selected, (value: Date | undefined) => {
+ let newHours = 0
+ let newMinutes = 0
+
+ if (value) {
+ newHours = value.getHours()
+ newMinutes = value.getMinutes()
+ }
+
+ hours.value = newHours
+ minutes.value = newMinutes
+ })
+
const hoursList: ComputedRef- = computed(() => [...Array(24).keys()].map((value) => ({
value,
date: set(new Date(currentDate.value.getTime()), { hours: value, minutes: minutes.value, seconds: 0 }),