Merge pull request #5987 from KumJungMin/fix/issue-v3-#5886

fix(Calendar): highlight range of month in MonthMode
pull/6506/head
Tuğçe Küçükoğlu 2024-09-25 15:03:18 +03:00 committed by GitHub
commit 508652963a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 8 deletions

View File

@ -704,17 +704,30 @@ export default {
return false; return false;
}, },
isMonthSelected(month) { isMonthSelected(month) {
if (this.isComparable()) { if (!this.isComparable()) return false;
let value = this.isRangeSelection() ? this.modelValue[0] : this.modelValue;
if (this.isMultipleSelection()) { if (this.isMultipleSelection()) {
return value.some((currentValue) => currentValue.getMonth() === month && currentValue.getFullYear() === this.currentYear); return this.modelValue.some((currentValue) => currentValue.getMonth() === month && currentValue.getFullYear() === this.currentYear);
} else if (this.isRangeSelection()) {
const [start, end] = this.modelValue;
const startYear = start ? start.getFullYear() : null;
const endYear = end ? end.getFullYear() : null;
const startMonth = start ? start.getMonth() : null;
const endMonth = end ? end.getMonth() : null;
if (!end) {
return startYear === this.currentYear && startMonth === month;
} else { } else {
return value.getMonth() === month && value.getFullYear() === this.currentYear; const currentDate = new Date(this.currentYear, month, 1);
} const startDate = new Date(startYear, startMonth, 1);
const endDate = new Date(endYear, endMonth, 1);
return currentDate >= startDate && currentDate <= endDate;
} }
return false; } else {
return this.modelValue.getMonth() === month && this.modelValue.getFullYear() === this.currentYear;
}
}, },
isYearSelected(year) { isYearSelected(year) {
if (!this.isComparable()) return false; if (!this.isComparable()) return false;