From 59d9d09c46ffbb8ee7e6d22460025c4cdcc9d2a7 Mon Sep 17 00:00:00 2001 From: Tin de Zeeuw Date: Wed, 28 Aug 2024 11:58:42 +0200 Subject: [PATCH] fix issue #14233: change isYearSelected function so it doesn't break when no date(s) is selected yet --- src/app/components/calendar/calendar.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/app/components/calendar/calendar.ts b/src/app/components/calendar/calendar.ts index ad25df2ec3a..96f0bde6f62 100644 --- a/src/app/components/calendar/calendar.ts +++ b/src/app/components/calendar/calendar.ts @@ -1836,13 +1836,11 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor { } isYearSelected(year: number) { - if (this.isComparable()) { - let value = this.isRangeSelection() ? this.value[0] : this.value; + if (!this.isComparable()) return false; + if (this.isMultipleSelection()) return false; - return !this.isMultipleSelection() ? value.getFullYear() === year : false; - } - - return false; + let value = this.isRangeSelection() ? this.value[0] : this.value; + return value ? value.getFullYear() === year : false; } isDateEquals(value: any, dateMeta: any) {