diff --git a/packages/core/client/src/schema-initializer/buttons/CustomFormItemInitializers.tsx b/packages/core/client/src/schema-initializer/buttons/CustomFormItemInitializers.tsx index 25b7218058..c9e4550ddd 100644 --- a/packages/core/client/src/schema-initializer/buttons/CustomFormItemInitializers.tsx +++ b/packages/core/client/src/schema-initializer/buttons/CustomFormItemInitializers.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { SchemaInitializer } from '../SchemaInitializer'; -import { gridRowColWrap, useCustomFormItemInitializerFields,useInheritsFormItemInitializerFields } from '../utils'; +import { gridRowColWrap, useCustomFormItemInitializerFields, useInheritsFormItemInitializerFields } from '../utils'; import { useCompile } from '../../schema-component'; // 表单里配置字段 @@ -10,25 +10,26 @@ export const CustomFormItemInitializers = (props: any) => { const compile = useCompile(); const { insertPosition, component } = props; const inheritFields = useInheritsFormItemInitializerFields(); - const fieldItems:any[]=[ + const fieldItems: any[] = [ { type: 'itemGroup', title: t('Configure fields'), children: useCustomFormItemInitializerFields(), }, - ] + ]; if (inheritFields?.length > 0) { inheritFields.forEach((inherit) => { - fieldItems.push( - { - type: 'divider', - }, - { - type: 'itemGroup', - title: t(`Parent collection fields`) + '(' + compile(`${Object.keys(inherit)[0]}`) + ')', - children: Object.values(inherit)[0], - }, - ); + Object.values(inherit)[0].length && + fieldItems.push( + { + type: 'divider', + }, + { + type: 'itemGroup', + title: t(`Parent collection fields`) + '(' + compile(`${Object.keys(inherit)[0]}`) + ')', + children: Object.values(inherit)[0], + }, + ); }); } return ( diff --git a/packages/core/client/src/schema-initializer/buttons/ReadPrettyFormItemInitializers.tsx b/packages/core/client/src/schema-initializer/buttons/ReadPrettyFormItemInitializers.tsx index ada8daec37..51a2b6dfe1 100644 --- a/packages/core/client/src/schema-initializer/buttons/ReadPrettyFormItemInitializers.tsx +++ b/packages/core/client/src/schema-initializer/buttons/ReadPrettyFormItemInitializers.tsx @@ -20,7 +20,7 @@ export const ReadPrettyFormItemInitializers = (props: any) => { ]; if (inheritFields?.length > 0) { inheritFields.forEach((inherit) => { - fieldItems.push( + Object.values(inherit)[0]?.length&&fieldItems.push( { type: 'divider', },