From 9af46a01544a56cff84e2a784f30e639dd3c39e6 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 8 Jan 2022 15:22:10 +0100 Subject: [PATCH] fix: flatpickr date not updating Fixes https://github.com/go-vikunja/api/issues/16 --- src/components/input/datepicker.vue | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/input/datepicker.vue b/src/components/input/datepicker.vue index afef20e7c..d2432295e 100644 --- a/src/components/input/datepicker.vue +++ b/src/components/input/datepicker.vue @@ -128,10 +128,6 @@ export default { date: null, show: false, changed: false, - - // Since flatpickr dates are strings, we need to convert them to native date objects. - // To make that work, we need a separate variable since flatpickr does not have a change event. - flatPickrDate: null, } }, components: { @@ -164,10 +160,6 @@ export default { handler: 'setDateValue', immediate: true, }, - flatPickrDate(newVal) { - this.date = createDateFromString(newVal) - this.updateData() - }, }, computed: { flatPickerConfig() { @@ -183,6 +175,17 @@ export default { }, } }, + // Since flatpickr dates are strings, we need to convert them to native date objects. + // To make that work, we need a separate variable since flatpickr does not have a change event. + flatPickrDate: { + set(newValue) { + this.date = createDateFromString(newValue) + this.updateData() + }, + get() { + return format(this.date, 'yyy-LL-dd H:mm') + }, + }, }, methods: { setDateValue(newVal) {