From 5178a93f738dc13553e0db93baecb8147c38a8eb Mon Sep 17 00:00:00 2001 From: Yury Uvarov Date: Tue, 17 Dec 2024 12:53:00 +0300 Subject: [PATCH] update handleClickMonthOrYear.ts --- .../handles/handleClick/handleClickMonthOrYear.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/package/src/scripts/handles/handleClick/handleClickMonthOrYear.ts b/package/src/scripts/handles/handleClick/handleClickMonthOrYear.ts index 7a5d803..ee9e5f9 100644 --- a/package/src/scripts/handles/handleClick/handleClickMonthOrYear.ts +++ b/package/src/scripts/handles/handleClick/handleClickMonthOrYear.ts @@ -22,15 +22,20 @@ const handleMultipleYearSelection = (self: Calendar, itemEl: HTMLElement) => { const dateMin = getDate(self.context.dateMin); const dateMax = getDate(self.context.dateMax); const monthCount = self.context.displayMonthsCount - 1; + const { columnID } = getColumnID(self, 'year'); const isBeforeMinDate = self.context.selectedMonth < dateMin.getMonth() && selectedYear <= dateMin.getFullYear(); - const isAfterMaxDate = self.context.selectedMonth > dateMax.getMonth() - monthCount && selectedYear >= dateMax.getFullYear(); + const isAfterMaxDate = self.context.selectedMonth > dateMax.getMonth() - monthCount + columnID && selectedYear >= dateMax.getFullYear(); const isBeforeMinYear = selectedYear < dateMin.getFullYear(); const isAfterMaxYear = selectedYear > dateMax.getFullYear(); const newSelectedYear = isBeforeMinDate || isBeforeMinYear ? dateMin.getFullYear() : isAfterMaxDate || isAfterMaxYear ? dateMax.getFullYear() : selectedYear; const newSelectedMonth = - isBeforeMinDate || isBeforeMinYear ? dateMin.getMonth() : isAfterMaxDate || isAfterMaxYear ? dateMax.getMonth() - monthCount : self.context.selectedMonth; + isBeforeMinDate || isBeforeMinYear + ? dateMin.getMonth() + : isAfterMaxDate || isAfterMaxYear + ? dateMax.getMonth() - monthCount + columnID + : self.context.selectedMonth; setContext(self, 'selectedYear', newSelectedYear); setContext(self, 'selectedMonth', newSelectedMonth as Range<12>);