From 757b466dc85e6d016fa84c291f23f2163df7a9ec Mon Sep 17 00:00:00 2001 From: linxianxi <47104575+linxianxi@users.noreply.github.com> Date: Mon, 10 Apr 2023 23:24:01 +0800 Subject: [PATCH] fix(antd): add helperContainer to antd array-items (#3780) --- packages/antd/src/array-items/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/antd/src/array-items/index.tsx b/packages/antd/src/array-items/index.tsx index fe07951e3a1..3d1abd9fd96 100644 --- a/packages/antd/src/array-items/index.tsx +++ b/packages/antd/src/array-items/index.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { useRef } from 'react' import { ArrayField } from '@formily/core' import { useField, @@ -74,6 +74,7 @@ const useAddition = () => { export const ArrayItems: ComposedArrayItems = observer((props) => { const field = useField() const prefixCls = usePrefixCls('formily-array-items') + const ref = useRef(null) const schema = useFieldSchema() const addition = useAddition() const dataSource = Array.isArray(field.value) ? field.value : [] @@ -89,6 +90,7 @@ export const ArrayItems: ComposedArrayItems = observer((props) => { >
{}} className={cls(prefixCls, props.className)} > @@ -96,6 +98,9 @@ export const ArrayItems: ComposedArrayItems = observer((props) => { useDragHandle lockAxis="y" helperClass={`${prefixCls}-sort-helper`} + helperContainer={() => + ref.current?.querySelector(`${prefixCls}-list`) + } onSortEnd={({ oldIndex, newIndex }) => { field.move(oldIndex, newIndex) }}