From 93937046a8667615dc119ead51dbbe5f06102a7c Mon Sep 17 00:00:00 2001 From: KumJungMin <37934668+KumJungMin@users.noreply.github.com> Date: Fri, 14 Jun 2024 14:28:04 +0900 Subject: [PATCH] fix: highlight range of year in yearMode --- .../primevue/src/datepicker/DatePicker.vue | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/primevue/src/datepicker/DatePicker.vue b/packages/primevue/src/datepicker/DatePicker.vue index c2770cf6e..9851aa820 100755 --- a/packages/primevue/src/datepicker/DatePicker.vue +++ b/packages/primevue/src/datepicker/DatePicker.vue @@ -727,17 +727,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 start === year || end === year || (start < year && end > year); + } else { + return value.getFullYear() === year; } - - return false; }, isDateEquals(value, dateMeta) { if (value) return value.getDate() === dateMeta.day && value.getMonth() === dateMeta.month && value.getFullYear() === dateMeta.year;