Skip to content

Commit 5b4821b

Browse files
committed
feat(dp): update calendar days view on typing & value is another view-month/year
1 parent 0cb144b commit 5b4821b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,23 @@ describe('IgxDatePicker', () => {
343343
const expectedDate = new Date(2025, 0, 2);
344344
expect(datePicker.value).toEqual(expectedDate);
345345
expect(datePicker.activeDate).toEqual(expectedDate);
346+
it('should update the calendar view and active date on typing a date that is not in the current view', fakeAsync(() => {
347+
const date = new Date(2025, 0, 1);
348+
datePicker.value = date;
349+
datePicker.open();
350+
fixture.detectChanges();
351+
352+
const input = fixture.debugElement.query(By.css('.igx-input-group__input'));
353+
input.nativeElement.focus();
354+
tick();
355+
fixture.detectChanges();
356+
357+
fixture.detectChanges();
358+
UIInteractions.simulateTyping('02/11/2025', input);
359+
360+
const expectedDate = new Date(2025, 10, 2);
361+
expect(datePicker.value).toEqual(expectedDate);
362+
expect(datePicker.activeDate).toEqual(expectedDate);
346363

347364
const activeDescendantDate = new Date(expectedDate.setHours(0, 0, 0, 0)).getTime().toString();
348365
expect(datePicker['_calendar'].activeDate).toEqual(expectedDate);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ export class IgxDatePickerComponent extends PickerBaseDirective implements Contr
160160
@Input({ transform: booleanAttribute })
161161
public showWeekNumbers: boolean;
162162

163+
164+
/**
165+
* Gets/Sets the date which is shown in the calendar picker and is highlighted.
166+
* By default it is the current date, or the value of the picker, if set.
167+
*/
163168
@Input()
164169
public get activeDate(): Date {
165170
const today = new Date(new Date().setHours(0, 0, 0, 0));
@@ -846,6 +851,9 @@ export class IgxDatePickerComponent extends PickerBaseDirective implements Contr
846851
this._dateValue = DateTimeUtil.isValidDate(value) ? value : DateTimeUtil.parseIsoDate(value);
847852
if (this._calendar) {
848853
this._calendar.selectDate(this._dateValue);
854+
this._calendar.activeDate = this.activeDate;
855+
this._calendar.viewDate = this.activeDate;
856+
this.cdr.detectChanges();
849857
}
850858
}
851859

0 commit comments

Comments
 (0)