From 8f60d0d33d6a2e0cb3f8d3653ea148ec6c52c124 Mon Sep 17 00:00:00 2001 From: Eduard Heller Date: Sat, 10 Feb 2024 01:38:15 +0100 Subject: [PATCH 1/3] Fix #14590 and #12286 - Single dates only calender not possible with hand typing --- src/app/components/calendar/calendar.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/calendar/calendar.ts b/src/app/components/calendar/calendar.ts index ce28618cce4..f9e747371a7 100755 --- a/src/app/components/calendar/calendar.ts +++ b/src/app/components/calendar/calendar.ts @@ -2740,7 +2740,7 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor { } } else if (value.every((v: any) => this.isSelectable(v.getDate(), v.getMonth(), v.getFullYear(), false))) { if (this.isRangeSelection()) { - isValid = value.length > 1 && value[1] > value[0] ? true : false; + isValid = value.length === 1 || (value.length > 1 && value[1] >= value[0] ? true : false); } } return isValid; From 7d1cc3376bbae76c79c3037595f113fccb474954 Mon Sep 17 00:00:00 2001 From: Eduard Heller Date: Sat, 10 Feb 2024 02:24:58 +0100 Subject: [PATCH 2/3] Changed isValidSelection to deny not selectable single dates in range mode --- src/app/components/calendar/calendar.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/app/components/calendar/calendar.ts b/src/app/components/calendar/calendar.ts index f9e747371a7..b112f5d6982 100755 --- a/src/app/components/calendar/calendar.ts +++ b/src/app/components/calendar/calendar.ts @@ -2733,16 +2733,14 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor { } isValidSelection(value: any): boolean { - let isValid = true; + let isValid = false; if (this.isSingleSelection()) { - if (!this.isSelectable(value.getDate(), value.getMonth(), value.getFullYear(), false)) { - isValid = false; - } - } else if (value.every((v: any) => this.isSelectable(v.getDate(), v.getMonth(), v.getFullYear(), false))) { - if (this.isRangeSelection()) { - isValid = value.length === 1 || (value.length > 1 && value[1] >= value[0] ? true : false); - } - } + return this.isSelectable(value.getDate(), value.getMonth(), value.getFullYear(), false); + } + isValid = value.every((v: any) => this.isSelectable(v.getDate(), v.getMonth(), v.getFullYear(), false)); + if (isValid && this.isRangeSelection()) { + isValid = value.length === 1 || (value.length > 1 && value[1] >= value[0] ? true : false); + } return isValid; } From ec3ca828ef3321606d057a438504e097b7d8a83e Mon Sep 17 00:00:00 2001 From: eduardheller89 <159040857+eduardheller89@users.noreply.github.com> Date: Mon, 12 Feb 2024 09:13:54 +0100 Subject: [PATCH 3/3] Simplified isValid statement --- src/app/components/calendar/calendar.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/app/components/calendar/calendar.ts b/src/app/components/calendar/calendar.ts index b112f5d6982..2bfb2b2d692 100755 --- a/src/app/components/calendar/calendar.ts +++ b/src/app/components/calendar/calendar.ts @@ -2733,13 +2733,12 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor { } isValidSelection(value: any): boolean { - let isValid = false; if (this.isSingleSelection()) { return this.isSelectable(value.getDate(), value.getMonth(), value.getFullYear(), false); } - isValid = value.every((v: any) => this.isSelectable(v.getDate(), v.getMonth(), v.getFullYear(), false)); + let isValid = value.every((v: any) => this.isSelectable(v.getDate(), v.getMonth(), v.getFullYear(), false)); if (isValid && this.isRangeSelection()) { - isValid = value.length === 1 || (value.length > 1 && value[1] >= value[0] ? true : false); + isValid = value.length === 1 || (value.length > 1 && value[1] >= value[0]); } return isValid; }