diff --git a/packages/core/client/src/schema-component/antd/association-field/InternalNester.tsx b/packages/core/client/src/schema-component/antd/association-field/InternalNester.tsx index 833f6c1e9..aa6566a27 100644 --- a/packages/core/client/src/schema-component/antd/association-field/InternalNester.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/InternalNester.tsx @@ -53,9 +53,18 @@ export const InternalNester = observer(
= (props) => { const f = useAttach(form.createVoidField({ ...field.props, basePath: '' })); const height = useFormBlockHeight(); const { token } = theme.useToken(); - + const { designable } = useDesignable(); return ( @@ -55,7 +55,7 @@ const FormComponent: React.FC = (props) => { .nb-grid-container { height: ${height ? height + 'px' : '100%'}; overflow-y: auto; - margin: 0px -${token.marginLG}px; + margin: 0px -${token.marginLG}px ${designable ? 0 : -token.marginLG}px; padding: 0px ${token.paddingLG}px; } `} diff --git a/packages/core/client/src/schema-component/antd/form-v2/hook.ts b/packages/core/client/src/schema-component/antd/form-v2/hook.ts index 82828ccfa..7f6f83fc6 100644 --- a/packages/core/client/src/schema-component/antd/form-v2/hook.ts +++ b/packages/core/client/src/schema-component/antd/form-v2/hook.ts @@ -11,7 +11,7 @@ import { theme } from 'antd'; import { useFieldSchema } from '@formily/react'; import { useDataBlockHeight } from '../../hooks/useBlockSize'; import { useDesignable } from '../../'; -import { useDataBlockRequest } from '../../../data-source'; +import { useCollection, useDataBlockRequest } from '../../../data-source'; import { useFormDataTemplates } from './Templates'; import { useBlockHeightProps } from '../../../block-provider/hooks/useBlockHeightProps'; @@ -31,12 +31,34 @@ export const useFormBlockHeight = () => { }); const hasFormActions = Object.keys(actionSchema?.properties || {}).length > 0; - const actionBarHeight = hasFormActions || designable ? token.controlHeight + 2 * token.marginLG : 2 * token.marginLG; + const isFormBlock = schema?.parent?.['x-decorator']?.includes?.('FormBlockProvider'); + const actionBarPadding = () => { + if (isFormBlock) { + return designable ? 2 : 1; + } + return 2; + }; + + const actionBarHeight = + hasFormActions || designable ? token.controlHeight + actionBarPadding() * token.marginLG : 1 * token.marginLG; const blockTitleHeaderHeight = title ? token.fontSizeLG * token.lineHeightLG + token.padding * 2 - 1 : 0; const { data } = useDataBlockRequest() || {}; const { count, pageSize } = (data as any)?.meta || ({} as any); const hasPagination = count > pageSize; - const paginationHeight = hasPagination ? token.controlHeightSM + 1 * token.paddingLG : 0; + const paginationHeight = hasPagination ? token.controlHeightSM + (designable ? 1 : 0) * token.paddingLG : 0; const dataTemplateHeight = display && enabled ? token.controlHeight + 2 * token.padding + token.margin : 0; - return height - actionBarHeight - token.paddingLG - blockTitleHeaderHeight - paginationHeight - dataTemplateHeight; + const blockBottomPadding = () => { + if (!isFormBlock && !hasPagination) { + return designable ? 1 : 0; + } + return 1; + }; + return ( + height - + actionBarHeight - + blockBottomPadding() * token.paddingLG - + blockTitleHeaderHeight - + paginationHeight - + dataTemplateHeight + ); };