Commit 72f225e9387d289ca323b9d834a5f2bde86ca93f

Authored by Sergio Crisostomo
1 parent 22ff9a62

Fix date manual input so it falls back to old value when parser don't parse the input

Showing 1 changed file with 3 additions and 3 deletions   Show diff stats
src/components/date-picker/picker.vue
... ... @@ -255,8 +255,9 @@
255 255 this.options.disabledDate;
256 256 const valueToTest = isArrayValue ? newDate : newDate[0];
257 257 const isDisabled = disabledDateFn && disabledDateFn(valueToTest);
  258 + const isValidDate = newDate.reduce((valid, date) => valid && date instanceof Date, true);
258 259  
259   - if (newValue !== oldValue && !isDisabled) {
  260 + if (newValue !== oldValue && !isDisabled && isValidDate) {
260 261 this.emitChange();
261 262 this.internalValue = newDate;
262 263 } else {
... ... @@ -324,7 +325,7 @@
324 325 }
325 326 }
326 327 } else if (typeof val === 'string' && type.indexOf('time') !== 0){
327   - val = parser(val, format) || val;
  328 + val = parser(val, format) || null;
328 329 }
329 330  
330 331 return (isRange || this.multiple) ? (val || []) : [val];
... ... @@ -344,7 +345,6 @@
344 345 }
345 346 },
346 347 onPick(dates, visible = false) {
347   -
348 348 if (this.multiple){
349 349 const allDates = [...this.internalValue, dates].filter(Boolean);
350 350 const timeStamps = allDates.map(date => date.getTime()).filter((ts, i, arr) => arr.indexOf(ts) === i); // filter away duplicates
... ...