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; }