From 15457562eaf3d4816a07cb4f3d1cbb291bd238ba Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Wed, 24 Jan 2018 10:24:54 +0100 Subject: [PATCH] Reset panel date when dates are null --- src/components/date-picker/panel/Date/date-range.vue | 12 +++++++++--- src/components/date-picker/panel/Date/date.vue | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/date-picker/panel/Date/date-range.vue b/src/components/date-picker/panel/Date/date-range.vue index 83e4eb8..b11951e 100644 --- a/src/components/date-picker/panel/Date/date-range.vue +++ b/src/components/date-picker/panel/Date/date-range.vue @@ -184,10 +184,16 @@ value(newVal) { const minDate = newVal[0] ? toDate(newVal[0]) : null; const maxDate = newVal[1] ? toDate(newVal[1]) : null; - this.dates = [minDate, maxDate]; + this.dates = [minDate, maxDate].sort(); + if (JSON.stringify(this.dates) === '[null,null]') { + const leftPanelDate = this.startDate || new Date(); + this.leftPanelDate = leftPanelDate, + this.rightPanelDate = new Date(leftPanelDate.getFullYear(), leftPanelDate.getMonth() + 1, leftPanelDate.getDate()); + } + this.rangeState = { - from: minDate, - to: maxDate, + from: this.dates[0], + to: this.dates[1], selecting: false }; }, diff --git a/src/components/date-picker/panel/Date/date.vue b/src/components/date-picker/panel/Date/date.vue index 3aaa90b..f69a2d0 100644 --- a/src/components/date-picker/panel/Date/date.vue +++ b/src/components/date-picker/panel/Date/date.vue @@ -138,6 +138,7 @@ watch: { value (newVal) { this.dates = newVal; + if (JSON.stringify(newVal) === '[null]') this.panelDate = this.startDate || new Date(); }, selectionMode(){ this.currentView = this.selectionMode; -- libgit2 0.21.4