diff --git a/src/components/DateInput.vue b/src/components/DateInput.vue index d2bd9f2b..a5585169 100644 --- a/src/components/DateInput.vue +++ b/src/components/DateInput.vue @@ -112,6 +112,10 @@ export default { return this.inputClass }, formattedDate() { + if (!this.selectedDate) { + return null + } + return typeof this.format === 'function' ? this.format(new Date(this.selectedDate)) : this.utils.formatDate( @@ -205,6 +209,11 @@ export default { * Parses a typed date and submits it, if valid */ handleKeyup() { + if (this.input.value === '') { + this.$emit('typed-date', null) + return + } + this.parsedDate = Date.parse( this.utils.parseDate( this.input.value, diff --git a/src/components/Datepicker.vue b/src/components/Datepicker.vue index 66749718..57fc2913 100644 --- a/src/components/Datepicker.vue +++ b/src/components/Datepicker.vue @@ -449,7 +449,7 @@ export default { * @param {Date} date */ handleTypedDate(date) { - this.selectDate(date.valueOf()) + this.selectDate(date ? date.valueOf() : null) }, /** * Focus the relevant element when the view changes @@ -530,6 +530,11 @@ export default { * @param {Number} timestamp */ selectDate(timestamp) { + if (!timestamp) { + this.selectedDate = null + return + } + const date = new Date(timestamp) this.selectedDate = date this.setPageDate(date)