Skip to content

Commit

Permalink
fix(kit): CalendarRange not update selectedActivePeriod, when `va…
Browse files Browse the repository at this point in the history
…lue` updates
  • Loading branch information
mdlufy committed Aug 14, 2024
1 parent fb150f8 commit cfe3356
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import {
HostListener,
Inject,
Input,
OnChanges,
Optional,
Output,
Self,
SimpleChanges,
} from '@angular/core';
import {
ALWAYS_FALSE_HANDLER,
Expand Down Expand Up @@ -47,7 +49,9 @@ import {takeUntil} from 'rxjs/operators';
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [TuiDestroyService],
})
export class TuiCalendarRangeComponent implements TuiWithOptionalMinMax<TuiDay> {
export class TuiCalendarRangeComponent
implements TuiWithOptionalMinMax<TuiDay>, OnChanges
{
@Input()
defaultViewedMonth: TuiMonth = TuiMonth.currentLocal();

Expand Down Expand Up @@ -108,6 +112,7 @@ export class TuiCalendarRangeComponent implements TuiWithOptionalMinMax<TuiDay>

valueChanges.pipe(tuiWatch(cdr), takeUntil(destroy$)).subscribe(value => {
this.value = value;
this.selectedActivePeriod = null;
});
}

Expand All @@ -121,6 +126,12 @@ export class TuiCalendarRangeComponent implements TuiWithOptionalMinMax<TuiDay>
this.value = this.previousValue;
}

ngOnChanges({value}: SimpleChanges): void {
if (value?.currentValue) {
this.selectedActivePeriod = null;
}
}

readonly monthOffset: TuiTypedMapper<[TuiMonth, number], TuiMonth> = (value, month) =>
value.append({month});

Expand Down

0 comments on commit cfe3356

Please sign in to comment.