Skip to content

Commit cb5f399

Browse files
authored
Merge pull request #886 from simbacod3/feature/add-calendar-instance-on-count-increment
feat(date-picker): Add calendar instance when count sub-property is incremented from external context
2 parents b42cdee + a36f758 commit cb5f399

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/VueDatePicker/components/DatePicker/DatePicker.vue

+11
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
presetDate,
145145
selectCurrentDate,
146146
updateTime,
147+
assignMonthAndYear,
147148
} = useDatePicker(props, emit, triggerCalendarTransition, updateFlowStep);
148149
const slots = useSlots();
149150
const { setHoverDate, getDayClassData, clearHoverDate } = useCalendarClass(modelValue, props);
@@ -175,6 +176,16 @@
175176
{ deep: true },
176177
);
177178
179+
watch(
180+
defaultedMultiCalendars,
181+
(newVal, oldVal) => {
182+
if (newVal.count - oldVal.count > 0) {
183+
assignMonthAndYear();
184+
}
185+
},
186+
{ deep: true },
187+
);
188+
178189
/**
179190
* Array of the dates from which calendar is built.
180191
* It also sets classes depending on picker modes, active dates, today, v-model.

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export const useDatePicker = (
161161
};
162162

163163
// Assign month and year values per date
164-
const assignMonthAndYear = (date: Date, fromMount = false): void => {
164+
const assignMonthAndYear = (date = new Date(), fromMount = false): void => {
165165
if (!defaultedMultiCalendars.value.count || !defaultedMultiCalendars.value.static || fromMount) {
166166
setCalendarMonthYear(0, getMonth(date), getYear(date));
167167
}
@@ -678,5 +678,6 @@ export const useDatePicker = (
678678
presetDate,
679679
selectCurrentDate,
680680
updateTime,
681+
assignMonthAndYear,
681682
};
682683
};

0 commit comments

Comments
 (0)