From b802aa550852bf3143e00a38d36a76267f1e4d4d Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 14 Nov 2022 16:45:03 +0800 Subject: [PATCH] fix(nc-gui): avoid keeping unnecessary props when switching column type --- .../nc-gui/composables/useColumnCreateStore.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/composables/useColumnCreateStore.ts b/packages/nc-gui/composables/useColumnCreateStore.ts index 9816b4e183..922b12464c 100644 --- a/packages/nc-gui/composables/useColumnCreateStore.ts +++ b/packages/nc-gui/composables/useColumnCreateStore.ts @@ -97,7 +97,19 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState const onUidtOrIdTypeChange = () => { const colProp = sqlUi.value.getDataTypeForUiType(formState.value as { uidt: UITypes }, idType ?? undefined) formState.value = { - ...formState.value, + ...(!isEdit.value && { + // only take title, column_name and uidt when creating a column + // to avoid the extra props from being taken (e.g. SingleLineText -> LTAR -> SingleLineText) + // to mess up the column creation + title: formState.value.title, + column_name: formState.value.column_name, + uidt: formState.value.uidt, + }), + ...(isEdit.value && { + // take the existing formState.value when editing a column + // LTAR is not available in this case + ...formState.value, + }), meta: {}, rqd: false, pk: false,