diff --git a/packages/nc-gui/components/cell/Duration.vue b/packages/nc-gui/components/cell/Duration.vue index 7c8f6bea83..1430ae9b0b 100644 --- a/packages/nc-gui/components/cell/Duration.vue +++ b/packages/nc-gui/components/cell/Duration.vue @@ -30,14 +30,32 @@ const durationType = computed(() => parseProp(column?.value?.meta)?.duration || const durationPlaceholder = computed(() => durationOptions[durationType.value].title) +const tempState = ref() + const localState = computed({ - get: () => convertMS2Duration(modelValue, durationType.value), + get: () => { + if (tempState.value === undefined) { + return convertMS2Duration(modelValue, durationType.value) + } + + return tempState.value + }, set: (val) => { + tempState.value = val + isEdited.value = true const res = convertDurationToSeconds(val, durationType.value) if (res._isValid) { durationInMS.value = res._sec } + + if (!val) { + emit('update:modelValue', null) + isEdited.value = false + tempState.value = undefined + } else { + emit('update:modelValue', durationInMS.value) + } }, }) @@ -63,7 +81,10 @@ const submitDuration = () => { if (isEdited.value) { emit('update:modelValue', durationInMS.value) } + isEdited.value = false + + tempState.value = undefined } const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!