Skip to content

Commit

Permalink
fix(datepicker): for issue #1962 (#1991)
Browse files Browse the repository at this point in the history
fixes #1962
Now activeDateChange event get fired then the date changed, before the event only gets fired then you use the arrows (back and forward buttons) in top of the calendar.
  • Loading branch information
CodingDK authored and valorkin committed Jul 18, 2017
1 parent 690d811 commit deb7f63
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/datepicker/datepicker-inner.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {
// tslint:disable-next-line:no-unused-variable
public ngOnChanges(changes: SimpleChanges): void {
this.refreshView();
this.checkIfActiveDateGotUpdated(changes.activeDate);
}

//Check if activeDate has been update and then emit the activeDateChange with the new date
private checkIfActiveDateGotUpdated(activeDate: any): void {
if (activeDate && !activeDate.firstChange) {
let previousValue = activeDate.previousValue;
if (previousValue && previousValue.getTime() !== activeDate.currentValue.getTime()) {
this.activeDateChange.emit(this.activeDate);
}
}
}

public setCompareHandler(handler: Function, type: string): void {
Expand Down Expand Up @@ -219,9 +230,6 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {
}

this.activeDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
if (isManual) {
this.selectionDone.emit(this.activeDate);
}
} else {
this.activeDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
this.datepickerMode = this.modes[this.modes.indexOf(this.datepickerMode) - 1];
Expand Down

0 comments on commit deb7f63

Please sign in to comment.