From 02fef4b57d35beb2d43cdfb148d3609a7a5bd505 Mon Sep 17 00:00:00 2001 From: Demirci Date: Sat, 2 Mar 2024 01:11:10 +0300 Subject: [PATCH] fix(date-dropdown): updated the current date when the props are changed --- .../date-dropdown/date-dropdown.tsx | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/core/src/components/date-dropdown/date-dropdown.tsx b/packages/core/src/components/date-dropdown/date-dropdown.tsx index 943c5068871..5019ddd9426 100644 --- a/packages/core/src/components/date-dropdown/date-dropdown.tsx +++ b/packages/core/src/components/date-dropdown/date-dropdown.tsx @@ -95,6 +95,8 @@ export class DateDropdown { @Watch('from') onDateRangeIdChange() { this.onRangeListSelect(this.dateRangeId); + this.updateCurrentDate(); + this.onDateSelect({ from: this.currentRangeValue.from, to: this.currentRangeValue.to, @@ -186,11 +188,7 @@ export class DateDropdown { if (isCustomRange && this.customRangeAllowed) { this.selectedDateRangeId = 'custom'; - this.currentRangeValue = { - id: this.selectedDateRangeId, - from: this.from, - to: this.to, - }; + this.updateCurrentDate(); return; } @@ -201,20 +199,25 @@ export class DateDropdown { ); this.selectedDateRangeId = 'custom'; - this.currentRangeValue = { - id: this.selectedDateRangeId, - from: this.from, - to: this.to, - }; + this.updateCurrentDate(); return; } } + private updateCurrentDate() { + this.currentRangeValue = { + id: this.selectedDateRangeId, + from: this.from, + to: this.to, + }; + } + private onDateSelect( rangeValue: { from: string; to: string; id: string }, preserveDropdown = true ) { + console.log('on data Chjange: ',rangeValue) this.dateRangeChange.emit(rangeValue); if (preserveDropdown) { @@ -246,6 +249,7 @@ export class DateDropdown { } private getButtonLabel() { + console.log('current range: ,',this.currentRangeValue); if (this.selectedDateRangeId === 'custom' && this.currentRangeValue?.from) { let range = this.currentRangeValue.from;