Skip to content

Commit

Permalink
When updating the calendar view, if daterange selected, don't change …
Browse files Browse the repository at this point in the history
…current month in view
  • Loading branch information
raymondcheung authored and fetrarij committed Mar 21, 2024
1 parent e874ad4 commit a7ede5a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/daterangepicker/daterangepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,11 @@ export class DaterangepickerComponent implements OnInit, OnChanges {
return;
}
if (this.startDate) {
// we want to stay on whatever months are in view if date range is set and both calendar sides have a month already. e.g. when
// user clicks on the end date, we want to stay on current month in view
if (this.leftCalendar.month && this.rightCalendar.month) {
return;
}
this.leftCalendar.month = this.startDate.clone().date(2);
if (!this.linkedCalendars && (this.endDate.month() !== this.startDate.month() || this.endDate.year() !== this.startDate.year())) {
this.rightCalendar.month = this.endDate.clone().date(2);
Expand Down

0 comments on commit a7ede5a

Please sign in to comment.