From 72f225e9387d289ca323b9d834a5f2bde86ca93f Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Wed, 24 Jan 2018 14:54:03 +0100 Subject: [PATCH] Fix date manual input so it falls back to old value when parser don't parse the input --- src/components/date-picker/picker.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/date-picker/picker.vue b/src/components/date-picker/picker.vue index 4f753e5..aa82060 100644 --- a/src/components/date-picker/picker.vue +++ b/src/components/date-picker/picker.vue @@ -255,8 +255,9 @@ this.options.disabledDate; const valueToTest = isArrayValue ? newDate : newDate[0]; const isDisabled = disabledDateFn && disabledDateFn(valueToTest); + const isValidDate = newDate.reduce((valid, date) => valid && date instanceof Date, true); - if (newValue !== oldValue && !isDisabled) { + if (newValue !== oldValue && !isDisabled && isValidDate) { this.emitChange(); this.internalValue = newDate; } else { @@ -324,7 +325,7 @@ } } } else if (typeof val === 'string' && type.indexOf('time') !== 0){ - val = parser(val, format) || val; + val = parser(val, format) || null; } return (isRange || this.multiple) ? (val || []) : [val]; @@ -344,7 +345,6 @@ } }, onPick(dates, visible = false) { - if (this.multiple){ 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 -- libgit2 0.21.4