Skip to content

Commit 93a2aff

Browse files
committed
feat(Calendar): recalc activeDate when views are changed #6275
1 parent 345fb9d commit 93a2aff

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

Diff for: projects/igniteui-angular/src/lib/calendar/calendar-base.ts

-1
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,6 @@ export class IgxCalendarBaseDirective implements ControlValueAccessor {
651651
this.selectRange(value, true);
652652
break;
653653
}
654-
this.resetActiveDate();
655654
}
656655

657656
/**

Diff for: projects/igniteui-angular/src/lib/calendar/calendar.component.html

+3-4
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ <h2 class="igx-calendar__header-date">
4545

4646
<div style="display: flex"
4747
[@animateChange]="animationAction"
48-
(@animateChange.done)="animationDone($event)" (focusout)="resetActiveDate()">
48+
(@animateChange.done)="animationDone($event)" >
4949
<igx-days-view *ngFor="let view of monthsViewNumber | IgxMonthViewSlots; index as i;" [changeDaysView]="true" #days
5050
[selection]="selection"
5151
[locale]="locale"
5252
[value]="value"
53-
[activeDate]="activeDate"
53+
[(activeDate)]="activeDate"
5454
[viewDate]="i | IgxGetViewDate:viewDate"
5555
[weekStart]="weekStart"
5656
[formatOptions]="formatOptions"
@@ -60,8 +60,7 @@ <h2 class="igx-calendar__header-date">
6060
[hideOutsideDays]="hideOutsideDays"
6161
[showWeekNumbers]="showWeekNumbers"
6262
(onViewChanging)="viewChanging($event)"
63-
(onDateSelection)="childClicked($event)"
64-
(activeDateChange)="activeDate = $event">
63+
(onDateSelection)="childClicked($event)">
6564
</igx-days-view>
6665
</div>
6766
</div>

Diff for: projects/igniteui-angular/src/lib/calendar/calendar.component.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
762762
this.callback(this.nextDate);
763763
}
764764
this.animationAction = ScrollMonth.NONE;
765+
this.resetActiveDate();
765766
}
766767

767768
/**
@@ -778,11 +779,12 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
778779
* @hidden
779780
* @internal
780781
*/
781-
public resetActiveDate(param?) {
782+
public resetActiveDate() {
782783
if (!this.monthViews) { return; }
783784
let dates = [];
784785
this.monthViews.map(mv => mv.dates).forEach(days => { dates = dates.concat(days.toArray()); });
785-
const date = dates.find(day => day.selected) || dates.find(day => day.isToday) || dates.find(d => d.isFocusable);
786+
const date = dates.find(day => day.selected && day.isCurrentMonth) || dates.find(day => day.isToday && day.isCurrentMonth)
787+
|| dates.find(d => d.isFocusable);
786788
if (date) {
787789
this.activeDate = date.date.date.toLocaleDateString();
788790
}
@@ -801,7 +803,6 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
801803
return;
802804
}
803805

804-
805806
const isPageDown = event.key === 'PageDown';
806807
const step = isPageDown ? 1 : -1;
807808
let monthView = this.daysView as IgxDaysViewComponent;
@@ -942,6 +943,14 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
942943
}
943944
}
944945

946+
@HostListener('focusout', ['$event'])
947+
public onPointerDown(event) {
948+
/* if (event.path.contains('igx-days-view')) {
949+
return;
950+
} */
951+
console.log(event);
952+
}
953+
945954
/**
946955
* @hidden
947956
* @internal

0 commit comments

Comments
 (0)