From 34e5c86a264c0711a4459c5cad34e68f3530476d Mon Sep 17 00:00:00 2001 From: Stefana Andreeva Date: Thu, 21 Feb 2019 10:41:46 +0200 Subject: [PATCH] fix(month picker): update mp value correctly #3126 --- .../month-picker.component.spec.ts | 2 +- .../month-picker/month-picker.component.ts | 22 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/projects/igniteui-angular/src/lib/calendar/month-picker/month-picker.component.spec.ts b/projects/igniteui-angular/src/lib/calendar/month-picker/month-picker.component.spec.ts index 8ed430fca51..d2314f1daed 100644 --- a/projects/igniteui-angular/src/lib/calendar/month-picker/month-picker.component.spec.ts +++ b/projects/igniteui-angular/src/lib/calendar/month-picker/month-picker.component.spec.ts @@ -193,7 +193,7 @@ describe('IgxMonthPicker', () => { const yearBtn = dom.query(By.css('.igx-calendar-picker__date')); expect(currentMonth.nativeElement.textContent.trim()).toEqual('Apr'); - expect(yearBtn.nativeElement.textContent.trim()).toMatch('2019'); + expect(yearBtn.nativeElement.textContent.trim()).toMatch('2022'); }); it('should navigate to the previous/next year.', () => { diff --git a/projects/igniteui-angular/src/lib/calendar/month-picker/month-picker.component.ts b/projects/igniteui-angular/src/lib/calendar/month-picker/month-picker.component.ts index 2866a717d3e..fbcd50720fe 100644 --- a/projects/igniteui-angular/src/lib/calendar/month-picker/month-picker.component.ts +++ b/projects/igniteui-angular/src/lib/calendar/month-picker/month-picker.component.ts @@ -135,8 +135,8 @@ export class IgxMonthPickerComponent extends IgxMonthPickerBase { this.yearAction = 'next'; this.viewDate = this.calendarModel.timedelta(this.viewDate, 'year', 1); - this._onChangeCallback(this.viewDate); - this.onSelection.emit(this.viewDate); + this.selectDate(this.viewDate); + this.onSelection.emit(this.selectedDates); } /** @@ -158,8 +158,8 @@ export class IgxMonthPickerComponent extends IgxMonthPickerBase { this.yearAction = 'prev'; this.viewDate = this.calendarModel.timedelta(this.viewDate, 'year', -1); - this._onChangeCallback(this.viewDate); - this.onSelection.emit(this.viewDate); + this.selectDate(this.viewDate); + this.onSelection.emit(this.selectedDates); } /** @@ -181,8 +181,8 @@ export class IgxMonthPickerComponent extends IgxMonthPickerBase { this.viewDate = new Date(event.getFullYear(), event.getMonth(), event.getDate()); this.activeView = CalendarView.DEFAULT; - this._onChangeCallback(this.viewDate); - this.onSelection.emit(this.viewDate); + this.selectDate(event); + this.onSelection.emit(this.selectedDates); requestAnimationFrame(() => { this.yearsBtn.nativeElement.focus(); @@ -193,10 +193,8 @@ export class IgxMonthPickerComponent extends IgxMonthPickerBase { * @hidden */ public selectMonth(event: Date) { - this.viewDate = new Date(event.getFullYear(), event.getMonth(), event.getDate()); - this._onChangeCallback(this.viewDate); - - this.onSelection.emit(this.viewDate); + this.selectDate(event); + this.onSelection.emit(this.selectedDates); } /** @@ -212,7 +210,7 @@ export class IgxMonthPickerComponent extends IgxMonthPickerBase { // TO DO: to be refactored after discussion on the desired behavior super.selectDate(value); - this.viewDate.setMonth(value.getMonth()); + this.viewDate = value; } /** @@ -222,7 +220,7 @@ export class IgxMonthPickerComponent extends IgxMonthPickerBase { // TO DO: to be refactored after discussion on the desired behavior if (value) { - this.viewDate.setMonth(value.getMonth()); + this.viewDate = this.selectedDates = value; } }