Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix(nc-gui): save expanded record on keyboard shortcut only if save record btn enabled

Ramesh Mane05023d68b1ca
diff --git a/packages/nc-gui/components/smartsheet/expanded-form/index.vue b/packages/nc-gui/components/smartsheet/expanded-form/index.vue
index 34c947eb88..9ad8858e6f 100644
--- a/packages/nc-gui/components/smartsheet/expanded-form/index.vue
+++ b/packages/nc-gui/components/smartsheet/expanded-form/index.vue
@@ -198,6 +198,16 @@ const isExpanded = useVModel(props, 'modelValue', emits, {
defaultValue: false,
})
+// check if the row is new and has some changes on LTAR/Links
+// this is to enable save if there are changes on LTAR/Links
+const isLTARChanged = computed(() => {
+ return isNew.value && row.value?.rowMeta?.ltarState && Object.keys(row.value?.rowMeta?.ltarState).length > 0
+})
+
+const isSaveRecordBtnDisabled = computed(() => {
+ return changedColumns.value.size === 0 && !isUnsavedFormExist.value && !isLTARChanged.value
+})
+
const onClose = (force = false) => {
if (force) {
isExpanded.value = false
@@ -472,6 +482,10 @@ useActiveKeydownListener(
return
}
+ if (!isAllowedAddNewRecord.value || isSaveRecordBtnDisabled.value) {
+ return
+ }
+
try {
if (isNew.value) {
await _save(rowState.value)
@@ -629,12 +643,6 @@ const modalProps = computed(() => {
return {}
})
-// check if the row is new and has some changes on LTAR/Links
-// this is to enable save if there are changes on LTAR/Links
-const isLTARChanged = computed(() => {
- return isNew.value && row.value?.rowMeta?.ltarState && Object.keys(row.value?.rowMeta?.ltarState).length > 0
-})
-
watch(
() => comments.value.length,
(commentCount) => {
@@ -764,7 +772,7 @@ export default {
<template #default="{ isAllowed }">
<NcButton
v-e="['c:row-expand:save']"
- :disabled="!isAllowed || (changedColumns.size === 0 && !isUnsavedFormExist && !isLTARChanged)"
+ :disabled="!isAllowed || isSaveRecordBtnDisabled"
:loading="isSaving"
class="nc-expand-form-save-btn !xs:(text-base) !h-7 !px-2"
data-testid="nc-expanded-form-save"