Skip to content

Commit

Permalink
fix(material/datepicker) call detectChanges before focusing active cell
Browse files Browse the repository at this point in the history
  • Loading branch information
zarend committed Jan 10, 2022
1 parent 906db9e commit c0f8ecf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/material/datepicker/month-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ 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();

this._focusActiveCell();
// Prevent unexpected default actions such as form submission.
event.preventDefault();
Expand Down
3 changes: 3 additions & 0 deletions src/material/datepicker/multi-year-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ export class MatMultiYearView<D> implements AfterContentInit, OnDestroy {
this.activeDateChange.emit(this.activeDate);
}

// Ensure the calendar body has the correct active cell.
this._changeDetectorRef.detectChanges();

this._focusActiveCell();
// Prevent unexpected default actions such as form submission.
event.preventDefault();
Expand Down
3 changes: 3 additions & 0 deletions src/material/datepicker/year-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ export class MatYearView<D> implements AfterContentInit, OnDestroy {
this.activeDateChange.emit(this.activeDate);
}

// Ensure the calendar body has the correct active cell.
this._changeDetectorRef.detectChanges();

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

0 comments on commit c0f8ecf

Please sign in to comment.