Skip to content

Commit 4cd2c7f

Browse files
committed
BugFixes
* Disabled date error for range value null * Dateformat problem
1 parent dd7780c commit 4cd2c7f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/components/calendar.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ export default {
167167
to: null
168168
}
169169
if (this.range) {
170-
let disabledDate = new Date(this.selectedDate[1])
170+
let endDate = this.selectedDate[1]
171+
let disabledDate = endDate ? new Date(endDate) : null
171172
disabledDate = (!this.disabledStartDate.from || disabledDate.getTime() < this.disabledStartDate.from.getTime()) ? disabledDate : this.disabledStartDate.from
172173
unSelectedDate.from = disabledDate
173174
unSelectedDate.to = this.disabledStartDate.from
@@ -209,15 +210,16 @@ export default {
209210
formattedValue () {
210211
if (!this.range) {
211212
return this.formatDate(this.selectedDate)
212-
} else if (this.selectedDate.filter(Boolean).length != 2) return null
213+
}
214+
else if (this.selectedDate.filter(Boolean).length != 2) return null
213215
return `${this.formatDate(this.selectedDate[0])} ${this.rangeSeperator} ${this.formatDate(this.selectedDate[1])}`
214216
}
215217
},
216218
methods: {
217219
formatDate(value) {
218220
if (!value) return null
219221
if (this.range && this.value.filter(Boolean).length === 0 ) return null
220-
return new Date(value).toLocaleDateString(this.locale, { ...this.dateFormat })
222+
return new Date(value).toLocaleDateString(this.lang, { ...this.dateFormat })
221223
},
222224
prevMount(picker) {
223225
const currentDate = picker === 'start' ? this.currentDate : this.currentDateEnd
@@ -252,7 +254,11 @@ export default {
252254
},
253255
emitInputAction () {
254256
this.$emit('input', this.selectedDate)
255-
this.close()
257+
if (this.range) {
258+
if (this.selectedDate.filter(Boolean).length === 2) this.close()
259+
} else {
260+
this.close()
261+
}
256262
},
257263
isInSelectedDate (date) {
258264
if (!this.range) return null

0 commit comments

Comments
 (0)