Skip to content

Commit

Permalink
fix(month picker): update mp value correctly #3126
Browse files Browse the repository at this point in the history
  • Loading branch information
SAndreeva committed Feb 21, 2019
1 parent 2c905e1 commit 34e5c86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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();
Expand All @@ -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);
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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;
}
}

Expand Down

0 comments on commit 34e5c86

Please sign in to comment.