From 2836df2f1072c544629cb8b87004b835d94663f7 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Fri, 29 Dec 2023 17:51:07 +0800 Subject: [PATCH] fix: view collection should set title value when sync form database (#3287) --- .../templates/components/PreviewFields.tsx | 8 ++++++-- .../templates/components/PreviewTable.tsx | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx b/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx index f67999766..e035f757c 100644 --- a/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx +++ b/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx @@ -82,7 +82,8 @@ const PreviewCom = (props) => { setDataSource([]); const fieldsData = Object.values(data?.data?.fields)?.map((v: any) => { if (v.source) { - return v; + const option = fields?.data.find((h) => h.name === v.name) || v; + return { ...v, uiSchema: option.uiSchema }; } else { return fields?.data.find((h) => h.name === v.name) || v; } @@ -205,7 +206,10 @@ const PreviewCom = (props) => { - handleFieldChange({ ...item, uiSchema: { ...item?.uiSchema, title: e.target.value } }, index) + handleFieldChange( + { ...item, uiSchema: { ...item?.uiSchema, title: e.target.value, rawTitle: e.target.value } }, + index, + ) } /> ); diff --git a/packages/core/client/src/collection-manager/templates/components/PreviewTable.tsx b/packages/core/client/src/collection-manager/templates/components/PreviewTable.tsx index fc81a4c89..dcddbd746 100644 --- a/packages/core/client/src/collection-manager/templates/components/PreviewTable.tsx +++ b/packages/core/client/src/collection-manager/templates/components/PreviewTable.tsx @@ -21,7 +21,7 @@ export const PreviewTable = (props) => { if (databaseView) { getPreviewData(); } - }, [form.values.fields]); + }, [viewName, schema]); useEffect(() => { const pColumns = formatPreviewColumns(fields);