Skip to content

Commit

Permalink
when clicking a range, dont select dates that go beyond the min and m…
Browse files Browse the repository at this point in the history
…ax date
  • Loading branch information
Allavaz authored and fetrarij committed Mar 21, 2024
1 parent a7ede5a commit 8aac897
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/daterangepicker/daterangepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1274,8 +1274,16 @@ export class DaterangepickerComponent implements OnInit, OnChanges {
this.showCalInRanges = true;
} else {
const dates = this.ranges[label];
this.startDate = dates[0].clone();
this.endDate = dates[1].clone();
if (this.minDate && dates[0].isBefore(this.minDate)) {
this.startDate = this.minDate;
} else {
this.startDate = dates[0].clone();
}
if (this.maxDate && dates[1].isAfter(this.maxDate)) {
this.endDate = this.maxDate;
} else {
this.endDate = dates[1].clone();
}
if (this.showRangeLabelOnInput && label !== this.locale.customRangeLabel) {
this.chosenLabel = label;
} else {
Expand Down

0 comments on commit 8aac897

Please sign in to comment.