diff --git a/packages/core/client/src/schema-settings/EnableChildCollections/DynamicComponent.tsx b/packages/core/client/src/schema-settings/EnableChildCollections/DynamicComponent.tsx index ee347bdfa..552af8b87 100644 --- a/packages/core/client/src/schema-settings/EnableChildCollections/DynamicComponent.tsx +++ b/packages/core/client/src/schema-settings/EnableChildCollections/DynamicComponent.tsx @@ -18,7 +18,10 @@ export const ChildDynamicComponent = observer( }); const compile = useCompile(); - const result = useMemo(() => [formVariabele, iterationVariabele].filter(Boolean), [formVariabele]); + const result = useMemo( + () => [formVariabele, iterationVariabele].filter(Boolean), + [formVariabele, iterationVariabele], + ); const scope = compile(result); useEffect(() => { onChange(fieldSchema.default); diff --git a/packages/core/client/src/schema-settings/VariableInput/hooks/useIterationVariable.ts b/packages/core/client/src/schema-settings/VariableInput/hooks/useIterationVariable.ts index e980da8f0..3c9a563d9 100644 --- a/packages/core/client/src/schema-settings/VariableInput/hooks/useIterationVariable.ts +++ b/packages/core/client/src/schema-settings/VariableInput/hooks/useIterationVariable.ts @@ -1,5 +1,5 @@ -import { Schema } from '@formily/react'; import { useMemo } from 'react'; +import { useTranslation } from 'react-i18next'; import { useCompile, useGetFilterOptions } from '../../../schema-component'; import { FieldOption, Option } from '../type'; @@ -27,7 +27,7 @@ const getChildren = ( label: compile(option.title), depth, // TODO: 现在是通过组件的名称来过滤能够被选择的选项,这样的坏处是不够精确,后续可以优化 - disabled: schema?.['x-component'] !== option.schema?.['x-component'], + disabled: schema && schema?.['x-component'] !== option.schema?.['x-component'], }; } @@ -64,6 +64,7 @@ export const useIterationVariable = ({ schema?: any; level?: number; }) => { + const { t } = useTranslation(); const compile = useCompile(); const getFilterOptions = useGetFilterOptions(); const loadChildren = (option: any): Promise => { @@ -103,15 +104,14 @@ export const useIterationVariable = ({ }, 5); }); }; - + const label = t('Current object'); const result = useMemo(() => { return ( blockForm && currentCollection !== rootCollection && { - label: `{{t("Current object")}}`, + label: label, value: '$iteration', key: '$iteration', - children: [], isLeaf: false, field: { target: currentCollection,