Skip to content

Commit c0f8ecf

Browse files
committed
fix(material/datepicker) call detectChanges before focusing active cell
1 parent 906db9e commit c0f8ecf

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/material/datepicker/month-view.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ export class MatMonthView<D> implements AfterContentInit, OnChanges, OnDestroy {
342342
this.activeDateChange.emit(this.activeDate);
343343
}
344344

345+
// Ensure the calendar body has the correct active cell.
346+
this._changeDetectorRef.detectChanges();
347+
345348
this._focusActiveCell();
346349
// Prevent unexpected default actions such as form submission.
347350
event.preventDefault();

src/material/datepicker/multi-year-view.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ export class MatMultiYearView<D> implements AfterContentInit, OnDestroy {
293293
this.activeDateChange.emit(this.activeDate);
294294
}
295295

296+
// Ensure the calendar body has the correct active cell.
297+
this._changeDetectorRef.detectChanges();
298+
296299
this._focusActiveCell();
297300
// Prevent unexpected default actions such as form submission.
298301
event.preventDefault();

src/material/datepicker/year-view.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ export class MatYearView<D> implements AfterContentInit, OnDestroy {
280280
this.activeDateChange.emit(this.activeDate);
281281
}
282282

283+
// Ensure the calendar body has the correct active cell.
284+
this._changeDetectorRef.detectChanges();
285+
283286
this._focusActiveCell();
284287
// Prevent unexpected default actions such as form submission.
285288
event.preventDefault();

0 commit comments

Comments
 (0)