From c69eaba40bdccfc45731aa68ea2cadd53a918441 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 5 May 2023 17:14:12 +0800 Subject: [PATCH] fix(nc-gui): incorrect datetime value after saving in expanded form --- packages/nc-gui/components/cell/DateTimePicker.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/components/cell/DateTimePicker.vue b/packages/nc-gui/components/cell/DateTimePicker.vue index 0c8f41cd25..47e000f24f 100644 --- a/packages/nc-gui/components/cell/DateTimePicker.vue +++ b/packages/nc-gui/components/cell/DateTimePicker.vue @@ -18,10 +18,10 @@ import { interface Props { modelValue?: string | null isPk?: boolean - isUpdateOutside: Record + isUpdatedFromCopyNPaste: Record } -const { modelValue, isPk, isUpdateOutside } = defineProps() +const { modelValue, isPk, isUpdatedFromCopyNPaste } = defineProps() const emit = defineEmits(['update:modelValue']) @@ -78,7 +78,7 @@ let localState = $computed({ // when copying a datetime cell, the copied value would be local time // when pasting a datetime cell, UTC (xcdb) will be saved in DB // we convert back to local time - if (column.value.title! in (isUpdateOutside ?? {})) { + if (column.value.title! in (isUpdatedFromCopyNPaste ?? {})) { localModelValue = dayjs(modelValue).utc().local() return localModelValue } @@ -86,7 +86,11 @@ let localState = $computed({ // if localModelValue is defined, show localModelValue instead // localModelValue is set in setter below if (localModelValue) { - return localModelValue + const res = localModelValue + // resetting localModelValue here + // e.g. save in expanded form -> render the correct modelValue + localModelValue = undefined + return res } // empty cell - use modelValue in local time