Skip to content

Commit

Permalink
fix(date-dropdown): updated the current date when the props are changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Demirci committed Mar 29, 2024
1 parent cb46c07 commit 02fef4b
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions packages/core/src/components/date-dropdown/date-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 02fef4b

Please sign in to comment.