Skip to content

Commit d9b296c

Browse files
committed
fix: multi-calendars not updating when entering date via text-input (fixes #894)
1 parent 669b28d commit d9b296c

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

src/VueDatePicker/VueDatePicker.vue

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
:no-overlay-focus="noOverlayFocus"
3939
:collapse="collapse"
4040
:get-input-rect="getInputRect"
41+
:is-text-input-date="isTextInputDate"
4142
@close-picker="closeMenu"
4243
@select-date="selectDate"
4344
@auto-apply="autoApplyValue"
@@ -157,6 +158,7 @@
157158
const shouldFocusNext = ref(false);
158159
const shiftKeyActive = ref(false);
159160
const collapse = ref(false);
161+
const isTextInputDate = ref(false);
160162
161163
const { setMenuFocused, setShiftKey } = useState();
162164
const { clearArrowNav } = useArrowNavigation();
@@ -447,12 +449,16 @@
447449
const validDate = Array.isArray(date) ? !date.some((d) => !validateDate(d)) : validateDate(date);
448450
const validTime = isValidTime(date);
449451
if (validDate && validTime) {
452+
isTextInputDate.value = true;
450453
internalModelValue.value = date;
451454
if (submit) {
452455
shouldFocusNext.value = tabbed;
453456
selectDate();
454457
emit('text-submit');
455458
}
459+
nextTick().then(() => {
460+
isTextInputDate.value = false;
461+
});
456462
}
457463
};
458464

src/VueDatePicker/components/DatePicker/DatePicker.vue

+7-7
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@
177177
);
178178
179179
watch(
180-
defaultedMultiCalendars,
181-
(newVal, oldVal) => {
182-
if (newVal.count - oldVal.count > 0) {
183-
assignMonthAndYear();
184-
}
185-
},
186-
{ deep: true },
180+
defaultedMultiCalendars,
181+
(newVal, oldVal) => {
182+
if (newVal.count - oldVal.count > 0) {
183+
assignMonthAndYear();
184+
}
185+
},
186+
{ deep: true },
187187
);
188188
189189
/**

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export const useDatePicker = (
107107
modelValue,
108108
(newVal, oldVal) => {
109109
if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
110-
mapInternalModuleValues();
110+
mapInternalModuleValues(props.isTextInputDate);
111111
}
112112
},
113113
{ deep: true },

src/VueDatePicker/components/DatepickerMenu.vue

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
noOverlayFocus: { type: Boolean as PropType<boolean>, default: false },
173173
collapse: { type: Boolean as PropType<boolean>, default: false },
174174
getInputRect: { type: Function as PropType<() => DOMRect>, default: () => ({}) },
175+
isTextInputDate: { type: Boolean as PropType<boolean>, default: false },
175176
});
176177
177178
const dpMenuRef = ref<HTMLElement | null>(null);

src/VueDatePicker/props.ts

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export const PickerBaseProps = {
181181
collapse: { type: Boolean as PropType<boolean>, default: false },
182182
menuWrapRef: { type: Object as PropType<HTMLElement | null>, default: null },
183183
getInputRect: { type: Function as PropType<() => DOMRect>, default: () => ({}) },
184+
isTextInputDate: { type: Boolean as PropType<boolean>, default: false },
184185
};
185186

186187
export type AllPropsType = ExtractPropTypes<typeof AllProps>;

0 commit comments

Comments
 (0)