From 2ea97541c6a2ab6eed56ed278e0011f11320d6c3 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Fri, 18 Aug 2023 15:17:18 +0800 Subject: [PATCH] fix: source collections not updated during synchronization in view collection (#2480) --- .../templates/components/PreviewFields.tsx | 7 ++++--- 1 file changed, 4 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 0305bd37d..49b0dfa95 100644 --- a/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx +++ b/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx @@ -30,6 +30,7 @@ const PreviewCom = (props) => { const [loading, setLoading] = useState(false); const [dataSource, setDataSource] = useState([]); const [sourceFields, setSourceFields] = useState([]); + const [sourceCollections, setSourceCollections] = useState(sources); const field: any = useField(); const form = useForm(); const { getCollection, getInterface, getCollectionFields, getInheritCollections, getParentCollectionFields } = @@ -38,7 +39,7 @@ const PreviewCom = (props) => { const initOptions = getOptions().filter((v) => !['relation', 'systemInfo'].includes(v.key)); useEffect(() => { const data = []; - sources.forEach((item) => { + sourceCollections.forEach((item) => { const collection = getCollection(item); const inherits = getInheritCollections(item); const result = inherits.map((v) => { @@ -70,8 +71,7 @@ const PreviewCom = (props) => { }); }); setSourceFields(data); - }, [sources, databaseView]); - + }, [sourceCollections, databaseView]); useEffect(() => { if (databaseView) { setLoading(true); @@ -92,6 +92,7 @@ const PreviewCom = (props) => { field.value = fieldsData; setDataSource(fieldsData); form.setValuesIn('sources', data.data?.sources); + setSourceCollections(data.data?.sources); } }).catch; }