Skip to content

Commit 0ff35ff

Browse files
authored
Merge pull request #8377 from IgniteUI/ddincheva/calendarBugFixs
Changing month in the calendar should not throws an exception
2 parents c59e8de + 0412a91 commit 0ff35ff

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

projects/igniteui-angular/src/lib/calendar/calendar.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h2 class="igx-calendar__header-date">
2323
</div>
2424

2525
<div *ngIf="isDefaultView" class="igx-calendar__body" [@animateView]="activeView" (@animateView.done)="viewRendered($event)" (swiperight)="previousMonth()"
26-
(swipeleft)="nextMonth()">
26+
(swipeleft)="nextMonth()" (pointerdown)="suppressBlur()">
2727
<div class="igx-calendar-picker">
2828
<div tabindex="0" class="igx-calendar-picker__prev" #prevMonthBtn
2929
igxCalendarScrollMonth [startScroll]="startPrevMonthScroll" [stopScroll]="stopMonthScroll" [ngStyle]="{

projects/igniteui-angular/src/lib/calendar/calendar.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
419419
* @internal
420420
*/
421421
private _monthsViewNumber = 1;
422-
423422
/**
424423
* @hidden
425424
* @internal
@@ -481,6 +480,11 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
481480
this.isKeydownTrigger = isKeydownTrigger;
482481
}
483482

483+
public suppressBlur() {
484+
this.monthViews?.forEach(d => d.shouldResetDate = false);
485+
if (this.daysView) { this.daysView.shouldResetDate = false; }
486+
}
487+
484488
/**
485489
* Change to next month
486490
*
@@ -540,6 +544,9 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
540544
} else if (this.monthScrollDirection === ScrollMonth.NEXT) {
541545
this.nextMonthBtn.nativeElement.focus();
542546
}
547+
if (event.key === KEYS.SPACE || event.key === KEYS.SPACE_IE || event.key === KEYS.ENTER) {
548+
this.resetActiveDate();
549+
}
543550

544551
this.monthScrollDirection = ScrollMonth.NONE;
545552
}
@@ -765,6 +772,7 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
765772
public viewRendered(event) {
766773
if (event.fromState !== 'void') {
767774
this.activeViewChanged.emit(this.activeView);
775+
if (this.activeView === 0) { this.resetActiveDate(); }
768776
}
769777
}
770778

projects/igniteui-angular/src/lib/calendar/days-view/days-view.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements Do
119119
*/
120120
public nextMonthView: IgxDaysViewComponent;
121121

122-
/**
123-
* @hidden
124-
*/
122+
/** @hidden */
125123
public prevMonthView: IgxDaysViewComponent;
126-
public _activeDate;
127-
private shouldResetDate = true;
124+
/** @hidden */
125+
public shouldResetDate = true;
126+
private _activeDate;
127+
128128

129129
/**
130130
* The default css class applied to the component.

0 commit comments

Comments
 (0)