Skip to content

Commit e68ce66

Browse files
committed
fix(material/datepicker): manually trigger change detect only if keyboard event is not trusted
1 parent 28d1cc0 commit e68ce66

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/material/datepicker/month-view.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,10 @@ export class MatMonthView<D> implements AfterContentInit, OnChanges, OnDestroy {
340340
this.activeDateChange.emit(this.activeDate);
341341
}
342342

343-
// Ensure the calendar body has the correct active cell.
344-
this._changeDetectorRef.detectChanges();
343+
if (!event.isTrusted) {
344+
// Manually triggered events in unit tests do not trigger change detection. Ensures that the calendar body focuses on the date that is assigned to `this.activeDate` in this method.
345+
this._changeDetectorRef.detectChanges();
346+
}
345347

346348
this._focusActiveCell();
347349
// Prevent unexpected default actions such as form submission.

0 commit comments

Comments
 (0)