Calendar: Months are not highlighted with selection-mode="multiple" (#3989)

* Fix Calendar month selection

* fix: highlight for selection mode only
pull/4452/head
Alexander Rozhkov 2023-09-05 04:23:07 +03:00 committed by GitHub
parent 3d5e1cd1db
commit 5c727bb7a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -435,13 +435,27 @@ export default {
},
isMonthSelected(month) {
if (this.isComparable()) {
if (this.view !== 'month') {
return false;
}
let value = this.isRangeSelection() ? this.value[0] : this.value;
return !this.isMultipleSelection() ? (value.getMonth() === month && value.getFullYear() === this.currentYear) : false;
const isMonthSelected = (valueDate) => valueDate.getMonth() === month && valueDate.getFullYear() === this.currentYear;
if (this.isMultipleSelection()) {
return value.some(isMonthSelected);
}
return isMonthSelected(value);
}
return false;
},
isYearSelected(year) {
if (this.isComparable()) {
if (this.view !== 'year') {
return false;
}
let value = this.isRangeSelection() ? this.value[0] : this.value;
return !this.isMultipleSelection() && this.isComparable() ? (value.getFullYear() === year) : false;
}