fix(association-field): array field move
This commit is contained in:
parent
f286534752
commit
3f4cd86465
@ -1,6 +1,8 @@
|
|||||||
import { CloseCircleOutlined } from '@ant-design/icons';
|
import { CloseCircleOutlined } from '@ant-design/icons';
|
||||||
import { ArrayField } from '@formily/core';
|
import { ArrayField } from '@formily/core';
|
||||||
|
import { spliceArrayState } from '@formily/core/lib/shared/internals';
|
||||||
import { RecursionField, observer, useFieldSchema } from '@formily/react';
|
import { RecursionField, observer, useFieldSchema } from '@formily/react';
|
||||||
|
import { action } from '@formily/reactive';
|
||||||
import { Button, Card, Divider } from 'antd';
|
import { Button, Card, Divider } from 'antd';
|
||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@ -40,9 +42,14 @@ const ToManyNester = observer((props) => {
|
|||||||
<CloseCircleOutlined
|
<CloseCircleOutlined
|
||||||
style={{ zIndex: 1000, position: 'absolute', color: '#a8a3a3' }}
|
style={{ zIndex: 1000, position: 'absolute', color: '#a8a3a3' }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const result = field.value;
|
action(() => {
|
||||||
result.splice(index, 1);
|
spliceArrayState(field as any, {
|
||||||
field.value = result;
|
startIndex: index,
|
||||||
|
deleteCount: 1,
|
||||||
|
});
|
||||||
|
field.value.splice(index, 1);
|
||||||
|
return field.onInput(field.value);
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user