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 | 184 | value(newVal) { |
| 185 | 185 | const minDate = newVal[0] ? toDate(newVal[0]) : null; |
| 186 | 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 | 194 | this.rangeState = { |
| 189 | - from: minDate, | |
| 190 | - to: maxDate, | |
| 195 | + from: this.dates[0], | |
| 196 | + to: this.dates[1], | |
| 191 | 197 | selecting: false |
| 192 | 198 | }; |
| 193 | 199 | }, | ... | ... |
src/components/date-picker/panel/Date/date.vue