From e0aa79469da52de9d4dd8298609de47701214770 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Tue, 22 Oct 2019 13:54:17 +0300 Subject: [PATCH] Fixed #70 - Poor handling of user input on Calendar --- src/components/calendar/Calendar.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/calendar/Calendar.vue b/src/components/calendar/Calendar.vue index bda18a33e..c20006120 100644 --- a/src/components/calendar/Calendar.vue +++ b/src/components/calendar/Calendar.vue @@ -312,6 +312,7 @@ export default { } } }, + oldViewDate: null, created() { this.updateCurrentMetaData(); this.updateInputFieldValue(this.value); @@ -349,7 +350,7 @@ export default { watch: { value(newValue) { this.updateCurrentMetaData(); - this.updateInputFieldValue(newValue); + this.updateInputFieldValue(newValue || this.inputFieldValue); } }, methods: { @@ -1541,6 +1542,7 @@ export default { catch(err) { //invalid date $vm.updateModel(null); + $vm.inputFieldValue = val; } }, focus: event => { @@ -1579,12 +1581,17 @@ export default { }; }, viewDate() { + let $vm = this; let propValue = this.value; if (propValue && Array.isArray(propValue)) { propValue = propValue[0]; } - return propValue || new Date(); + let vDate = propValue || $vm.oldViewDate || new Date(); + + $vm.oldViewDate = vDate; + + return vDate; }, containerClass() { return [