fix(calendar): should markForCheck when properties are changed (#15102)

* fix(calendar): should markForCheck when properties are changed

* fix test
This commit is contained in:
Andrew Seguin
2019-03-05 09:23:14 -08:00
committed by Joey Perrott
parent 4614fb8e52
commit 679bdb6601
2 changed files with 7 additions and 9 deletions
+5 -9
View File
@@ -188,17 +188,13 @@ describe('MatCalendar', () => {
});
it('should move focus to the active cell when the view changes', () => {
const activeCell =
calendarBodyEl.querySelector('.mat-calendar-body-active')! as HTMLElement;
spyOn(activeCell, 'focus').and.callThrough();
fixture.detectChanges();
zone.simulateZoneExit();
expect(activeCell.focus).not.toHaveBeenCalled();
calendarInstance.currentView = 'multi-year';
fixture.detectChanges();
const activeCell =
calendarBodyEl.querySelector('.mat-calendar-body-active')! as HTMLElement;
spyOn(activeCell, 'focus').and.callThrough();
zone.simulateZoneExit();
expect(activeCell.focus).toHaveBeenCalled();
+2
View File
@@ -262,6 +262,7 @@ export class MatCalendar<D> implements AfterContentInit, AfterViewChecked, OnDes
set activeDate(value: D) {
this._clampedActiveDate = this._dateAdapter.clampDate(value, this.minDate, this.maxDate);
this.stateChanges.next();
this._changeDetectorRef.markForCheck();
}
private _clampedActiveDate: D;
@@ -270,6 +271,7 @@ export class MatCalendar<D> implements AfterContentInit, AfterViewChecked, OnDes
set currentView(value: MatCalendarView) {
this._currentView = value;
this._moveFocusOnNextTick = true;
this._changeDetectorRef.markForCheck();
}
private _currentView: MatCalendarView;