From e2c6a36d701f1d0e0a5102d4d92559fb48bfa6b1 Mon Sep 17 00:00:00 2001 From: KumJungMin <37934668+KumJungMin@users.noreply.github.com> Date: Fri, 28 Jun 2024 08:33:21 +0900 Subject: [PATCH] fix: highlight range of year in yearMode --- components/lib/calendar/Calendar.vue | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/components/lib/calendar/Calendar.vue b/components/lib/calendar/Calendar.vue index 9f2104153c..7605f52d60 100755 --- a/components/lib/calendar/Calendar.vue +++ b/components/lib/calendar/Calendar.vue @@ -717,17 +717,18 @@ export default { return false; }, isYearSelected(year) { - if (this.isComparable()) { - let value = this.isRangeSelection() ? this.modelValue[0] : this.modelValue; + if (!this.isComparable()) return false; - if (this.isMultipleSelection()) { - return value.some((currentValue) => currentValue.getFullYear() === year); - } else { - return value.getFullYear() === year; - } - } + if (this.isMultipleSelection()) { + return this.modelValue.some((currentValue) => currentValue.getFullYear() === year); + } else if (this.isRangeSelection()) { + const start = this.modelValue[0] ? this.modelValue[0].getFullYear() : null; + const end = this.modelValue[1] ? this.modelValue[1].getFullYear() : null; - return false; + return start === year || end === year || (start < year && end > year); + } else { + return this.modelValue.getFullYear() === year; + } }, isDateEquals(value, dateMeta) { if (value) return value.getDate() === dateMeta.day && value.getMonth() === dateMeta.month && value.getFullYear() === dateMeta.year;