Commit bc39c5c1d7eb781c7d2120551ccac66fb49cdac7

Authored by Aresn
Committed by GitHub
2 parents e9f3d00f ba3ad889

Merge pull request #4256 from SergioCrisostomo/fix-4249

Use last selected multiple date in date panel navigation
src/components/date-picker/panel/Date/date.vue
... ... @@ -150,7 +150,8 @@
150 150 watch: {
151 151 value (newVal) {
152 152 this.dates = newVal;
153   - this.panelDate = this.startDate || (this.multiple ? this.dates[this.dates.length - 1] : this.dates[0]) || new Date();
  153 + const panelDate = this.multiple ? this.dates[this.dates.length - 1] : (this.startDate || this.dates[0]);
  154 + this.panelDate = panelDate || new Date();
154 155 },
155 156 currentView (currentView) {
156 157 this.$emit('on-selection-mode-change', currentView);
... ... @@ -170,7 +171,7 @@
170 171 const isDifferentYear = date.getFullYear() !== this.panelDate.getFullYear();
171 172 const isDifferentMonth = isDifferentYear || date.getMonth() !== this.panelDate.getMonth();
172 173 if (isDifferentYear || isDifferentMonth){
173   - this.panelDate = date;
  174 + if (!this.multiple) this.panelDate = date;
174 175 }
175 176 }
176 177 },
... ...
src/components/date-picker/picker.vue
... ... @@ -646,7 +646,6 @@
646 646 }
647 647 },
648 648 onPick(dates, visible = false, type) {
649   - dates = this.parseDate(dates);
650 649 if (this.multiple){
651 650 const pickedTimeStamp = dates.getTime();
652 651 const indexOfPickedDate = this.internalValue.findIndex(date => date && date.getTime() === pickedTimeStamp);
... ... @@ -654,6 +653,7 @@
654 653 const timeStamps = allDates.map(date => date.getTime()).filter((ts, i, arr) => arr.indexOf(ts) === i && i !== indexOfPickedDate); // filter away duplicates
655 654 this.internalValue = timeStamps.map(ts => new Date(ts));
656 655 } else {
  656 + dates = this.parseDate(dates);
657 657 this.internalValue = Array.isArray(dates) ? dates : [dates];
658 658 }
659 659  
... ...