Skip to content

Commit

Permalink
Fix for issue valor-software#1962
Browse files Browse the repository at this point in the history
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 committed May 22, 2017
1 parent ead8d52 commit 62ebc7f
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 62ebc7f

Please sign in to comment.