From 164f10a072fec2430af14cc0b713bd5e5ea3b0cb Mon Sep 17 00:00:00 2001 From: Alexander Gunbin Date: Wed, 18 Oct 2023 11:22:19 -0600 Subject: [PATCH 1/2] 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) { From 503d2740da2e294eb8025e68a0242395881767c1 Mon Sep 17 00:00:00 2001 From: Alexander Gunbin Date: Thu, 19 Oct 2023 05:48:18 -0600 Subject: [PATCH 2/2] fix: prettier fix --- src/app/components/calendar/calendar.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/components/calendar/calendar.ts b/src/app/components/calendar/calendar.ts index e0ca1d1b9b7..8ce6c6a4b29 100755 --- a/src/app/components/calendar/calendar.ts +++ b/src/app/components/calendar/calendar.ts @@ -1672,7 +1672,9 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor { } isYearDisabled(year: number) { - return Array(12).fill(0).every((v, month) => this.isMonthDisabled(month, year)); + return Array(12) + .fill(0) + .every((v, month) => this.isMonthDisabled(month, year)); } isYearSelected(year: number) {