Skip to content

Commit

Permalink
fix(material/datepicker): manually trigger change detect only if keyb…
Browse files Browse the repository at this point in the history
…oard event is not trusted
  • Loading branch information
zarend committed Jan 12, 2022
1 parent 28d1cc0 commit e68ce66
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/material/datepicker/month-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,10 @@ export class MatMonthView<D> implements AfterContentInit, OnChanges, OnDestroy {
this.activeDateChange.emit(this.activeDate);
}

// Ensure the calendar body has the correct active cell.
this._changeDetectorRef.detectChanges();
if (!event.isTrusted) {
// 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.
this._changeDetectorRef.detectChanges();
}

this._focusActiveCell();
// Prevent unexpected default actions such as form submission.
Expand Down

0 comments on commit e68ce66

Please sign in to comment.