Skip to content
This repository was archived by the owner on Apr 17, 2022. It is now read-only.

Commit 8bdba8b

Browse files
committed
fix: Time picker doesn't auto-apply value (#10)
1 parent 788f8a7 commit 8bdba8b

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

src/Vue3DatePicker/Vue3DatePicker.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
@selectDate="selectDate"
7878
@dpOpen="recalculatePosition"
7979
@autoApply="autoApplyValue"
80+
@timeUpdate="timeUpdate"
8081
>
8182
<template v-for="(slot, i) in slotList" #[slot]="args" :key="i">
8283
<slot :name="slot" v-bind="{ ...args }" />
@@ -365,6 +366,12 @@
365366
}
366367
};
367368
369+
const timeUpdate = (): void => {
370+
if (props.autoApply) {
371+
emitModelValue();
372+
}
373+
};
374+
368375
defineExpose({
369376
closeMenu,
370377
selectDate,

src/Vue3DatePicker/components/Calendar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
import { useCalendar } from '../utils/composition/calendar';
109109
import { mapSlots } from '../utils/composition/slots';
110110
111-
const emit = defineEmits(['update:internalModelValue', 'closePicker', 'selectDate', 'autoApply']);
111+
const emit = defineEmits(['update:internalModelValue', 'closePicker', 'selectDate', 'autoApply', 'timeUpdate']);
112112
113113
const props = defineProps({
114114
weekStart: { type: [Number, String] as PropType<number | string>, default: 1 },

src/Vue3DatePicker/components/DatepickerMenu.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
@closePicker="$emit('closePicker')"
4444
@selectDate="$emit('selectDate')"
4545
@autoApply="$emit('autoApply', $event)"
46+
@timeUpdate="$emit('timeUpdate')"
4647
@update:internalModelValue="$emit('update:internalModelValue', $event)"
4748
>
4849
<template v-for="(slot, i) in slotList" #[slot]="args" :key="i">
@@ -59,7 +60,14 @@
5960
import { DynamicClass, IDateFilter, IFormat, InternalModuleValue, ITimeValue } from '../interfaces';
6061
import { mapSlots } from '../utils/composition/slots';
6162
62-
const emit = defineEmits(['update:internalModelValue', 'closePicker', 'selectDate', 'dpOpen', 'autoApply']);
63+
const emit = defineEmits([
64+
'update:internalModelValue',
65+
'closePicker',
66+
'selectDate',
67+
'dpOpen',
68+
'autoApply',
69+
'timeUpdate',
70+
]);
6371
const props = defineProps({
6472
uid: { type: String as PropType<string>, default: 'dp' },
6573
internalModelValue: { type: [Date, Array] as PropType<InternalModuleValue>, default: null },

src/Vue3DatePicker/utils/composition/calendar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ export const useCalendar = (props: UseCalendar, emit: VueEmit): IUseCalendar =>
253253
} else if (!props.range && !isRange(dateValue)) {
254254
modelValue.value = setDateTime(dateValue as Date, hours.value as number, minutes.value as number);
255255
}
256+
emit('timeUpdate');
256257
};
257258

258259
/**

0 commit comments

Comments
 (0)