From 2a8001ff4736a0a6e868ab05fcb028c6bd32cf2d Mon Sep 17 00:00:00 2001 From: KumJungMin <37934668+KumJungMin@users.noreply.github.com> Date: Fri, 14 Jun 2024 21:32:05 +0900 Subject: [PATCH] fix: highlight range of year in datePicker (#6760) --- components/lib/calendar/Calendar.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/components/lib/calendar/Calendar.js b/components/lib/calendar/Calendar.js index 40c361ace4..1e306f21f6 100644 --- a/components/lib/calendar/Calendar.js +++ b/components/lib/calendar/Calendar.js @@ -2354,17 +2354,18 @@ export const Calendar = React.memo( }; const isYearSelected = (year) => { - if (isComparable()) { - let value = isRangeSelection() ? props.value[0] : props.value; + if (!isComparable()) return false; - if (isMultipleSelection()) { - return value.some((currentValue) => currentValue.getFullYear() === year); - } + if (isMultipleSelection()) { + return props.value.some((v) => v.getFullYear() === year); + } else if (isRangeSelection()) { + const start = props.value[0] ? props.value[0].getFullYear() : null; + const end = props.value[1] ? props.value[1].getFullYear() : null; - return value.getFullYear() === year; + return start === year || end === year || (start < year && end > year); + } else { + return props.value.getFullYear() === year; } - - return false; }; const switchViewButtonDisabled = () => {