From 4065ef3b3e4635bc6423dd40478bbf997f7aead9 Mon Sep 17 00:00:00 2001 From: Mohan MU Date: Thu, 5 Sep 2024 19:39:01 +0530 Subject: [PATCH 1/4] fix(kit): CalendarRange click again on selected item not switch to item date --- .../kit/components/calendar-range/calendar-range.component.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/kit/components/calendar-range/calendar-range.component.ts b/projects/kit/components/calendar-range/calendar-range.component.ts index 13b6b3c773ef..88220951fcb3 100644 --- a/projects/kit/components/calendar-range/calendar-range.component.ts +++ b/projects/kit/components/calendar-range/calendar-range.component.ts @@ -178,6 +178,9 @@ export class TuiCalendarRange implements OnInit, OnChanges { this.selectedActivePeriod = item; this.updateValue(item.range.dayLimit(this.min, this.max)); this.itemChange.emit(item); + this.defaultViewedMonth = + (this.items.length ? this.value?.to : this.value?.from) || + this.defaultViewedMonth; } else if (this.activePeriod !== null) { this.selectedActivePeriod = null; this.updateValue(null); From 992389e8055601807a6948a9847153b2e63ef7a5 Mon Sep 17 00:00:00 2001 From: Mohan MU Date: Fri, 6 Sep 2024 22:23:26 +0530 Subject: [PATCH 2/4] fix --- .../components/calendar-range/calendar-range.component.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/projects/kit/components/calendar-range/calendar-range.component.ts b/projects/kit/components/calendar-range/calendar-range.component.ts index 88220951fcb3..ad27370a6d3e 100644 --- a/projects/kit/components/calendar-range/calendar-range.component.ts +++ b/projects/kit/components/calendar-range/calendar-range.component.ts @@ -96,6 +96,7 @@ export class TuiCalendarRange implements OnInit, OnChanges { ?.pipe(tuiWatch(inject(ChangeDetectorRef)), takeUntilDestroyed()) .subscribe((value) => { this.value = value; + this.defaultViewedMonth = this.value?.to || this.defaultViewedMonth; }); } @@ -178,9 +179,7 @@ export class TuiCalendarRange implements OnInit, OnChanges { this.selectedActivePeriod = item; this.updateValue(item.range.dayLimit(this.min, this.max)); this.itemChange.emit(item); - this.defaultViewedMonth = - (this.items.length ? this.value?.to : this.value?.from) || - this.defaultViewedMonth; + this.defaultViewedMonth = this.value?.to || this.defaultViewedMonth; } else if (this.activePeriod !== null) { this.selectedActivePeriod = null; this.updateValue(null); From 7d84f9fc4d43729c2f7ebb720dabe36907492f79 Mon Sep 17 00:00:00 2001 From: Mohan MU Date: Fri, 6 Sep 2024 22:49:49 +0530 Subject: [PATCH 3/4] fix(kit): range --- .../kit/components/calendar-range/calendar-range.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/kit/components/calendar-range/calendar-range.component.ts b/projects/kit/components/calendar-range/calendar-range.component.ts index ad27370a6d3e..6efc986411fc 100644 --- a/projects/kit/components/calendar-range/calendar-range.component.ts +++ b/projects/kit/components/calendar-range/calendar-range.component.ts @@ -96,7 +96,7 @@ export class TuiCalendarRange implements OnInit, OnChanges { ?.pipe(tuiWatch(inject(ChangeDetectorRef)), takeUntilDestroyed()) .subscribe((value) => { this.value = value; - this.defaultViewedMonth = this.value?.to || this.defaultViewedMonth; + this.defaultViewedMonth = this.value?.to ?? this.defaultViewedMonth; }); } @@ -179,7 +179,7 @@ export class TuiCalendarRange implements OnInit, OnChanges { this.selectedActivePeriod = item; this.updateValue(item.range.dayLimit(this.min, this.max)); this.itemChange.emit(item); - this.defaultViewedMonth = this.value?.to || this.defaultViewedMonth; + this.defaultViewedMonth = this.value?.to ?? this.defaultViewedMonth; } else if (this.activePeriod !== null) { this.selectedActivePeriod = null; this.updateValue(null); From 1ed2068eda7aa36932202859a1bdf1a476bf80c3 Mon Sep 17 00:00:00 2001 From: Mohan MU Date: Mon, 9 Sep 2024 21:27:21 +0530 Subject: [PATCH 4/4] fix(kit): fix defaultViewedMonth initialization in CalendarRange component --- .../components/calendar-range/calendar-range.component.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/projects/kit/components/calendar-range/calendar-range.component.ts b/projects/kit/components/calendar-range/calendar-range.component.ts index 6efc986411fc..e251c181bddd 100644 --- a/projects/kit/components/calendar-range/calendar-range.component.ts +++ b/projects/kit/components/calendar-range/calendar-range.component.ts @@ -96,7 +96,7 @@ export class TuiCalendarRange implements OnInit, OnChanges { ?.pipe(tuiWatch(inject(ChangeDetectorRef)), takeUntilDestroyed()) .subscribe((value) => { this.value = value; - this.defaultViewedMonth = this.value?.to ?? this.defaultViewedMonth; + this.initDefaultViewedMonth(); }); } @@ -179,12 +179,13 @@ export class TuiCalendarRange implements OnInit, OnChanges { this.selectedActivePeriod = item; this.updateValue(item.range.dayLimit(this.min, this.max)); this.itemChange.emit(item); - this.defaultViewedMonth = this.value?.to ?? this.defaultViewedMonth; } else if (this.activePeriod !== null) { this.selectedActivePeriod = null; this.updateValue(null); this.itemChange.emit(null); } + + this.initDefaultViewedMonth(); } protected onMonthChange(month: TuiMonth): void {