From 164f10a072fec2430af14cc0b713bd5e5ea3b0cb Mon Sep 17 00:00:00 2001 From: Alexander Gunbin Date: Wed, 18 Oct 2023 11:22:19 -0600 Subject: [PATCH] fix: added checking for each month when checking the disabled year --- src/app/components/calendar/calendar.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/app/components/calendar/calendar.ts b/src/app/components/calendar/calendar.ts index 4224bad5250..e0ca1d1b9b7 100755 --- a/src/app/components/calendar/calendar.ts +++ b/src/app/components/calendar/calendar.ts @@ -1660,17 +1660,19 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor { return false; } - isMonthDisabled(month: number) { - for (let day = 1; day < this.getDaysCountInMonth(month, this.currentYear) + 1; day++) { - if (this.isSelectable(day, month, this.currentYear, false)) { + isMonthDisabled(month: number, year?: number) { + const yearToCheck = year ?? this.currentYear; + + for (let day = 1; day < this.getDaysCountInMonth(month, yearToCheck) + 1; day++) { + if (this.isSelectable(day, month, yearToCheck, false)) { return false; } } return true; } - isYearDisabled(year) { - return !this.isSelectable(1, this.currentMonth, year, false); + isYearDisabled(year: number) { + return Array(12).fill(0).every((v, month) => this.isMonthDisabled(month, year)); } isYearSelected(year: number) {