Skip to content

Commit

Permalink
DatePicker: Move logic to resetDate method (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheyan authored Sep 18, 2020
1 parent ce162b8 commit fac3c7b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/date-picker/src/panel/date.vue
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,8 @@
value(val) {
if (this.selectionMode === 'dates' && this.value) return;
if (isDate(val)) {
this.date = new Date(val);
} else {
this.date = this.getDefaultValue();
}
// Reset the internal `date` data property when the `value` prop changes
this.resetDate();
},
defaultValue(val) {
Expand Down Expand Up @@ -264,9 +261,13 @@
this.userInputTime = null;
},
// resetDate() {
// this.date = new Date(this.date);
// },
resetDate() {
if (isDate(this.value)) {
this.date = new Date(this.value);
} else {
this.date = this.getDefaultValue();
}
},
showMonthPicker() {
this.currentView = 'month';
Expand Down

0 comments on commit fac3c7b

Please sign in to comment.