From 3f4cd86465512e71bdb8776858d7215408b317c0 Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 30 May 2023 10:12:58 +0800 Subject: [PATCH] fix(association-field): array field move --- .../antd/association-field/Nester.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/association-field/Nester.tsx b/packages/core/client/src/schema-component/antd/association-field/Nester.tsx index 33339666a..a065b5936 100644 --- a/packages/core/client/src/schema-component/antd/association-field/Nester.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/Nester.tsx @@ -1,6 +1,8 @@ import { CloseCircleOutlined } from '@ant-design/icons'; import { ArrayField } from '@formily/core'; +import { spliceArrayState } from '@formily/core/lib/shared/internals'; import { RecursionField, observer, useFieldSchema } from '@formily/react'; +import { action } from '@formily/reactive'; import { Button, Card, Divider } from 'antd'; import React, { useContext } from 'react'; import { useTranslation } from 'react-i18next'; @@ -40,9 +42,14 @@ const ToManyNester = observer((props) => { { - const result = field.value; - result.splice(index, 1); - field.value = result; + action(() => { + spliceArrayState(field as any, { + startIndex: index, + deleteCount: 1, + }); + field.value.splice(index, 1); + return field.onInput(field.value); + }); }} />