Skip to content

Commit

Permalink
fix(showRangeLabelOnInput): Showing the preset label doesn't work for…
Browse files Browse the repository at this point in the history
… the first time with supplied date

#45
  • Loading branch information
fetrarij committed Sep 12, 2018
1 parent 8c5ac5e commit 4bdaaeb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions demo/src/app/custom-ranges/custom-ranges.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export class CustomRangesComponent implements OnInit {
this.minDate = moment().subtract(3, 'days');

this.alwaysShowCalendars = true;
this.keepCalendarOpeningWithRange = false;
this.showRangeLabelOnInput = false;
this.keepCalendarOpeningWithRange = true;
this.showRangeLabelOnInput = true;
this.selected = {startDate: moment().subtract(1, 'days'), endDate: moment().subtract(1, 'days')};
}
rangeClicked(range) {
Expand Down
10 changes: 8 additions & 2 deletions src/daterangepicker/daterangepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,14 @@ export class DaterangepickerComponent implements OnInit {
updateElement() {
if (!this.singleDatePicker && this.autoUpdateInput) {
if (this.startDate && this.endDate) {
this.chosenLabel = this.startDate.format(this.locale.format) +
this.locale.separator + this.endDate.format(this.locale.format); }
// if we use ranges and should show range label on inpu
if (this.rangesArray.length && this.showRangeLabelOnInput === true && this.chosenRange) {
this.chosenLabel = this.chosenRange;
} else {
this.chosenLabel = this.startDate.format(this.locale.format) +
this.locale.separator + this.endDate.format(this.locale.format);
}
}
} else if ( this.autoUpdateInput) {
this.chosenLabel = this.startDate.format(this.locale.format);
}
Expand Down

0 comments on commit 4bdaaeb

Please sign in to comment.