Merge pull request #3678 from SergioCrisostomo/datepicker

Fix multidate parser value types, prevent undefined in focusedDate
This commit is contained in:
Aresn 2018-05-23 14:42:59 +08:00 committed by GitHub
commit 3076b0d24f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -651,7 +651,7 @@
this.internalValue = Array.isArray(dates) ? dates : [dates];
}
this.focusedDate = this.internalValue[0];
if (this.internalValue[0]) this.focusedDate = this.internalValue[0];
this.focusedTime = {
...this.focusedTime,
time: this.internalValue.map(extractTime)

View file

@ -226,7 +226,15 @@ export const TYPE_VALUE_RESOLVER_MAP = {
formatter: (value, format) => {
return value.filter(Boolean).map(date => formatDate(date, format)).join(',');
},
parser: (text, format) => text.split(',').map(string => parseDate(string.trim(), format))
parser: (value, format) => {
const values = typeof value === 'string' ? value.split(',') : value;
return values.map(value => {
if (value instanceof Date) return value;
if (typeof value === 'string') value = value.trim();
else if (typeof value !== 'number' && !value) value = '';
return parseDate(value, format);
});
}
},
number: {
formatter(value) {