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,7 +150,8 @@
150 watch: { 150 watch: {
151 value (newVal) { 151 value (newVal) {
152 this.dates = newVal; 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 currentView (currentView) { 156 currentView (currentView) {
156 this.$emit('on-selection-mode-change', currentView); 157 this.$emit('on-selection-mode-change', currentView);
@@ -170,7 +171,7 @@ @@ -170,7 +171,7 @@
170 const isDifferentYear = date.getFullYear() !== this.panelDate.getFullYear(); 171 const isDifferentYear = date.getFullYear() !== this.panelDate.getFullYear();
171 const isDifferentMonth = isDifferentYear || date.getMonth() !== this.panelDate.getMonth(); 172 const isDifferentMonth = isDifferentYear || date.getMonth() !== this.panelDate.getMonth();
172 if (isDifferentYear || isDifferentMonth){ 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,7 +646,6 @@
646 } 646 }
647 }, 647 },
648 onPick(dates, visible = false, type) { 648 onPick(dates, visible = false, type) {
649 - dates = this.parseDate(dates);  
650 if (this.multiple){ 649 if (this.multiple){
651 const pickedTimeStamp = dates.getTime(); 650 const pickedTimeStamp = dates.getTime();
652 const indexOfPickedDate = this.internalValue.findIndex(date => date && date.getTime() === pickedTimeStamp); 651 const indexOfPickedDate = this.internalValue.findIndex(date => date && date.getTime() === pickedTimeStamp);
@@ -654,6 +653,7 @@ @@ -654,6 +653,7 @@
654 const timeStamps = allDates.map(date => date.getTime()).filter((ts, i, arr) => arr.indexOf(ts) === i && i !== indexOfPickedDate); // filter away duplicates 653 const timeStamps = allDates.map(date => date.getTime()).filter((ts, i, arr) => arr.indexOf(ts) === i && i !== indexOfPickedDate); // filter away duplicates
655 this.internalValue = timeStamps.map(ts => new Date(ts)); 654 this.internalValue = timeStamps.map(ts => new Date(ts));
656 } else { 655 } else {
  656 + dates = this.parseDate(dates);
657 this.internalValue = Array.isArray(dates) ? dates : [dates]; 657 this.internalValue = Array.isArray(dates) ? dates : [dates];
658 } 658 }
659 659