Commit 15457562eaf3d4816a07cb4f3d1cbb291bd238ba
1 parent
b52e02e4
Reset panel date when dates are null
Showing
2 changed files
with
10 additions
and
3 deletions
Show diff stats
src/components/date-picker/panel/Date/date-range.vue
| @@ -184,10 +184,16 @@ | @@ -184,10 +184,16 @@ | ||
| 184 | value(newVal) { | 184 | value(newVal) { |
| 185 | const minDate = newVal[0] ? toDate(newVal[0]) : null; | 185 | const minDate = newVal[0] ? toDate(newVal[0]) : null; |
| 186 | const maxDate = newVal[1] ? toDate(newVal[1]) : null; | 186 | const maxDate = newVal[1] ? toDate(newVal[1]) : null; |
| 187 | - this.dates = [minDate, maxDate]; | 187 | + this.dates = [minDate, maxDate].sort(); |
| 188 | + if (JSON.stringify(this.dates) === '[null,null]') { | ||
| 189 | + const leftPanelDate = this.startDate || new Date(); | ||
| 190 | + this.leftPanelDate = leftPanelDate, | ||
| 191 | + this.rightPanelDate = new Date(leftPanelDate.getFullYear(), leftPanelDate.getMonth() + 1, leftPanelDate.getDate()); | ||
| 192 | + } | ||
| 193 | + | ||
| 188 | this.rangeState = { | 194 | this.rangeState = { |
| 189 | - from: minDate, | ||
| 190 | - to: maxDate, | 195 | + from: this.dates[0], |
| 196 | + to: this.dates[1], | ||
| 191 | selecting: false | 197 | selecting: false |
| 192 | }; | 198 | }; |
| 193 | }, | 199 | }, |
src/components/date-picker/panel/Date/date.vue
| @@ -138,6 +138,7 @@ | @@ -138,6 +138,7 @@ | ||
| 138 | watch: { | 138 | watch: { |
| 139 | value (newVal) { | 139 | value (newVal) { |
| 140 | this.dates = newVal; | 140 | this.dates = newVal; |
| 141 | + if (JSON.stringify(newVal) === '[null]') this.panelDate = this.startDate || new Date(); | ||
| 141 | }, | 142 | }, |
| 142 | selectionMode(){ | 143 | selectionMode(){ |
| 143 | this.currentView = this.selectionMode; | 144 | this.currentView = this.selectionMode; |