Commit 15457562eaf3d4816a07cb4f3d1cbb291bd238ba

Authored by Sergio Crisostomo
1 parent b52e02e4

Reset panel date when dates are null

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
... ... @@ -138,6 +138,7 @@
138 138 watch: {
139 139 value (newVal) {
140 140 this.dates = newVal;
  141 + if (JSON.stringify(newVal) === '[null]') this.panelDate = this.startDate || new Date();
141 142 },
142 143 selectionMode(){
143 144 this.currentView = this.selectionMode;
... ...