Skip to content

Commit 198f77b

Browse files
feat(range-picker): update calendar when value is updated (#10004)
Co-authored-by: Konstantin Dinev <[email protected]>
1 parent a6f6df7 commit 198f77b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,18 @@ describe('IgxDateRangePicker', () => {
758758

759759
disabled$.complete();
760760
}));
761+
762+
it('should update the calendar while it\'s open and the value has been updated', fakeAsync(() => {
763+
dateRange.open();
764+
tick();
765+
fixture.detectChanges();
766+
767+
const range = { start: new Date(), end: new Date(new Date().setDate(new Date().getDate() + 1)) };
768+
dateRange.value = range;
769+
fixture.detectChanges();
770+
771+
expect((dateRange as any).calendar.selectedDates.length).toBeGreaterThan(0);
772+
}));
761773
});
762774

763775
describe('Two Inputs', () => {
@@ -1170,6 +1182,18 @@ describe('IgxDateRangePicker', () => {
11701182
disabled$.complete();
11711183
}));
11721184

1185+
it('should update the calendar while it\'s open and the value has been updated', fakeAsync(() => {
1186+
dateRange.open();
1187+
tick();
1188+
fixture.detectChanges();
1189+
1190+
const range = { start: new Date(), end: new Date(new Date().setDate(new Date().getDate() + 1)) };
1191+
dateRange.value = range;
1192+
fixture.detectChanges();
1193+
1194+
expect((dateRange as any).calendar.selectedDates.length).toBeGreaterThan(0);
1195+
}));
1196+
11731197
describe('Data binding', () => {
11741198
it('should properly update component value with ngModel bound to projected inputs - #7353', fakeAsync(() => {
11751199
fixture = TestBed.createComponent(DateRangeTwoInputsNgModelTestComponent);

projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ export class IgxDateRangePickerComponent extends PickerBaseDirective
767767
private updateValue(value: DateRange) {
768768
this._value = value ? value : null;
769769
this.updateInputs();
770+
this.updateCalendar();
770771
}
771772

772773
private updateValidityOnBlur() {
@@ -847,6 +848,9 @@ export class IgxDateRangePickerComponent extends PickerBaseDirective
847848
}
848849

849850
private updateCalendar(): void {
851+
if (!this.calendar) {
852+
return;
853+
}
850854
this.calendar.disabledDates = [];
851855
const minValue = this.parseMinValue(this.minValue);
852856
if (minValue) {

0 commit comments

Comments
 (0)