fix(association-field): array field move

This commit is contained in:
chenos 2023-05-30 10:12:58 +08:00
parent f286534752
commit 3f4cd86465

View File

@ -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) => {
<CloseCircleOutlined
style={{ zIndex: 1000, position: 'absolute', color: '#a8a3a3' }}
onClick={() => {
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);
});
}}
/>
</div>