@@ -230,7 +230,9 @@ export class MatMonthView<D> implements AfterContentInit, OnChanges, OnDestroy {
230230 /** Handles when a new date is selected. */
231231 _dateSelected ( event : MatCalendarUserEvent < number > ) {
232232 const date = event . value ;
233- const selectedDate = this . _getDateFromDayOfMonth ( date ) ;
233+ const selectedYear = this . _dateAdapter . getYear ( this . activeDate ) ;
234+ const selectedMonth = this . _dateAdapter . getMonth ( this . activeDate ) ;
235+ const selectedDate = this . _dateAdapter . createDate ( selectedYear , selectedMonth , date ) ;
234236 let rangeStartDate : number | null ;
235237 let rangeEndDate : number | null ;
236238
@@ -250,26 +252,6 @@ export class MatMonthView<D> implements AfterContentInit, OnChanges, OnDestroy {
250252 this . _changeDetectorRef . markForCheck ( ) ;
251253 }
252254
253- /**
254- * Takes the index of a calendar body cell wrapped in in an event as argument. For the date that
255- * corresponds to the given cell, set `activeDate` to that date and fire `activeDateChange` with
256- * that date.
257- *
258- * This fucntion is used to match each component's model of the active date with the calendar
259- * body cell that was focused. It updates its value of `activeDate` synchronously and updates the
260- * parent's value asynchonously via the `activeDateChange` event. The child component receives an
261- * updated value asynchronously via the `activeCell` Input.
262- */
263- _updateActiveDate ( event : MatCalendarUserEvent < number > ) {
264- const month = event . value ;
265- const oldActiveDate = this . _activeDate ;
266- this . activeDate = this . _getDateFromDayOfMonth ( month ) ;
267-
268- if ( this . _dateAdapter . compareDate ( oldActiveDate , this . activeDate ) ) {
269- this . activeDateChange . emit ( this . _activeDate ) ;
270- }
271- }
272-
273255 /** Handles keydown events on the calendar body when calendar is in month view. */
274256 _handleCalendarBodyKeydown ( event : KeyboardEvent ) : void {
275257 // TODO(mmalerba): We currently allow keyboard navigation to disabled dates, but just prevent
@@ -345,10 +327,9 @@ export class MatMonthView<D> implements AfterContentInit, OnChanges, OnDestroy {
345327
346328 if ( this . _dateAdapter . compareDate ( oldActiveDate , this . activeDate ) ) {
347329 this . activeDateChange . emit ( this . activeDate ) ;
348-
349- this . _focusActiveCellAfterViewChecked ( ) ;
350330 }
351331
332+ this . _focusActiveCell ( ) ;
352333 // Prevent unexpected default actions such as form submission.
353334 event . preventDefault ( ) ;
354335 }
@@ -395,11 +376,6 @@ export class MatMonthView<D> implements AfterContentInit, OnChanges, OnDestroy {
395376 this . _matCalendarBody . _focusActiveCell ( movePreview ) ;
396377 }
397378
398- /** Focuses the active cell after change detection has run and the microtask queue is empty. */
399- _focusActiveCellAfterViewChecked ( ) {
400- this . _matCalendarBody . _scheduleFocusActiveCellAfterViewChecked ( ) ;
401- }
402-
403379 /** Called when the user has activated a new cell and the preview needs to be updated. */
404380 _previewChanged ( { event, value : cell } : MatCalendarUserEvent < MatCalendarCell < D > | null > ) {
405381 if ( this . _rangeStrategy ) {
@@ -422,18 +398,6 @@ export class MatMonthView<D> implements AfterContentInit, OnChanges, OnDestroy {
422398 }
423399 }
424400
425- /**
426- * Takes a day of the month and returns a new date in the same month and year as the currently
427- * active date. The returned date will have the same day of the month as the argument date.
428- */
429- private _getDateFromDayOfMonth ( dayOfMonth : number ) : D {
430- return this . _dateAdapter . createDate (
431- this . _dateAdapter . getYear ( this . activeDate ) ,
432- this . _dateAdapter . getMonth ( this . activeDate ) ,
433- dayOfMonth ,
434- ) ;
435- }
436-
437401 /** Initializes the weekdays. */
438402 private _initWeekdays ( ) {
439403 const firstDayOfWeek = this . _dateAdapter . getFirstDayOfWeek ( ) ;
0 commit comments