Commit 3076b0d24f5cbbcd369a4b2922d003a6e477a0e2
Committed by
GitHub
Merge pull request #3678 from SergioCrisostomo/datepicker
Fix multidate parser value types, prevent undefined in focusedDate
Showing
2 changed files
with
10 additions
and
2 deletions
Show diff stats
src/components/date-picker/picker.vue
| ... | ... | @@ -651,7 +651,7 @@ |
| 651 | 651 | this.internalValue = Array.isArray(dates) ? dates : [dates]; |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | - this.focusedDate = this.internalValue[0]; | |
| 654 | + if (this.internalValue[0]) this.focusedDate = this.internalValue[0]; | |
| 655 | 655 | this.focusedTime = { |
| 656 | 656 | ...this.focusedTime, |
| 657 | 657 | time: this.internalValue.map(extractTime) | ... | ... |
src/components/date-picker/util.js
| ... | ... | @@ -226,7 +226,15 @@ export const TYPE_VALUE_RESOLVER_MAP = { |
| 226 | 226 | formatter: (value, format) => { |
| 227 | 227 | return value.filter(Boolean).map(date => formatDate(date, format)).join(','); |
| 228 | 228 | }, |
| 229 | - parser: (text, format) => text.split(',').map(string => parseDate(string.trim(), format)) | |
| 229 | + parser: (value, format) => { | |
| 230 | + const values = typeof value === 'string' ? value.split(',') : value; | |
| 231 | + return values.map(value => { | |
| 232 | + if (value instanceof Date) return value; | |
| 233 | + if (typeof value === 'string') value = value.trim(); | |
| 234 | + else if (typeof value !== 'number' && !value) value = ''; | |
| 235 | + return parseDate(value, format); | |
| 236 | + }); | |
| 237 | + } | |
| 230 | 238 | }, |
| 231 | 239 | number: { |
| 232 | 240 | formatter(value) { | ... | ... |