Fix date toggle in "multiple mode"

This commit is contained in:
Sergio Crisostomo 2018-02-02 11:36:11 +01:00
parent abb0cc87cf
commit 88d24200e8

View file

@ -356,8 +356,10 @@
},
onPick(dates, visible = false) {
if (this.multiple){
const pickedTimeStamp = dates.getTime();
const indexOfPickedDate = this.internalValue.findIndex(date => date && date.getTime() === pickedTimeStamp);
const allDates = [...this.internalValue, dates].filter(Boolean);
const timeStamps = allDates.map(date => date.getTime()).filter((ts, i, arr) => arr.indexOf(ts) === i); // filter away duplicates
const timeStamps = allDates.map(date => date.getTime()).filter((ts, i, arr) => arr.indexOf(ts) === i && i !== indexOfPickedDate); // filter away duplicates
this.internalValue = timeStamps.map(ts => new Date(ts));
} else {
this.internalValue = Array.isArray(dates) ? dates : [dates];