From aececf1952cc6efdc8ffa90ac6b84f7e5f521e4d Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Sun, 16 Jul 2023 16:59:03 +0800 Subject: [PATCH] fix: view inherited collection field reported error (#2249) --- .../Configuration/ViewInheritedField.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/collection-manager/Configuration/ViewInheritedField.tsx b/packages/core/client/src/collection-manager/Configuration/ViewInheritedField.tsx index 78e15f928..892823bf3 100644 --- a/packages/core/client/src/collection-manager/Configuration/ViewInheritedField.tsx +++ b/packages/core/client/src/collection-manager/Configuration/ViewInheritedField.tsx @@ -3,7 +3,7 @@ import { ISchema } from '@formily/react'; import { uid } from '@formily/shared'; import cloneDeep from 'lodash/cloneDeep'; import set from 'lodash/set'; -import React, { useState } from 'react'; +import React, { useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useAPIClient, useRequest } from '../../api-client'; import { RecordProvider, useRecord } from '../../record-provider'; @@ -65,14 +65,21 @@ export const ViewCollectionField = (props) => { export const ViewFieldAction = (props) => { const { scope, getContainer, item: record, children } = props; - const { getInterface } = useCollectionManager(); + const { getInterface, collections } = useCollectionManager(); const [visible, setVisible] = useState(false); const [schema, setSchema] = useState({}); const api = useAPIClient(); const { t } = useTranslation(); const compile = useCompile(); const [data, setData] = useState({}); - + const currentCollections = useMemo(() => { + return collections.map((v) => { + return { + label: compile(v.title), + value: v.name, + }; + }); + }, []); return ( @@ -113,6 +120,7 @@ export const ViewFieldAction = (props) => { getContainer, showReverseFieldConfig: !data?.reverseField, createOnly: !true, + collections: currentCollections, ...scope, }} />