Skip to content

feat(date-picker): Add calendar instance when count sub-property is incremented from external context #886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/VueDatePicker/components/DatePicker/DatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
presetDate,
selectCurrentDate,
updateTime,
assignMonthAndYear,
} = useDatePicker(props, emit, triggerCalendarTransition, updateFlowStep);
const slots = useSlots();
const { setHoverDate, getDayClassData, clearHoverDate } = useCalendarClass(modelValue, props);
Expand Down Expand Up @@ -175,6 +176,16 @@
{ deep: true },
);

watch(
defaultedMultiCalendars,
(newVal, oldVal) => {
if (newVal.count - oldVal.count > 0) {
assignMonthAndYear();
}
},
{ deep: true },
);

/**
* Array of the dates from which calendar is built.
* It also sets classes depending on picker modes, active dates, today, v-model.
Expand Down
3 changes: 2 additions & 1 deletion src/VueDatePicker/components/DatePicker/date-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export const useDatePicker = (
};

// Assign month and year values per date
const assignMonthAndYear = (date: Date, fromMount = false): void => {
const assignMonthAndYear = (date = new Date(), fromMount = false): void => {
if (!defaultedMultiCalendars.value.count || !defaultedMultiCalendars.value.static || fromMount) {
setCalendarMonthYear(0, getMonth(date), getYear(date));
}
Expand Down Expand Up @@ -678,5 +678,6 @@ export const useDatePicker = (
presetDate,
selectCurrentDate,
updateTime,
assignMonthAndYear,
};
};
Loading