fix(association-field): sub-table cannot move (#2727)
This commit is contained in:
parent
01271598fc
commit
4092451bc9
@ -7,14 +7,12 @@ import { action } from '@formily/reactive';
|
|||||||
import { isArr } from '@formily/shared';
|
import { isArr } from '@formily/shared';
|
||||||
import { Button } from 'antd';
|
import { Button } from 'antd';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import { Table } from '../table-v2/Table';
|
import { Table } from '../table-v2/Table';
|
||||||
import { useAssociationFieldContext } from './hooks';
|
import { useAssociationFieldContext } from './hooks';
|
||||||
|
|
||||||
export const SubTable: any = observer(
|
export const SubTable: any = observer(
|
||||||
(props: any) => {
|
(props: any) => {
|
||||||
const { field } = useAssociationFieldContext<ArrayField>();
|
const { field } = useAssociationFieldContext<ArrayField>();
|
||||||
const { t } = useTranslation();
|
|
||||||
const move = (fromIndex: number, toIndex: number) => {
|
const move = (fromIndex: number, toIndex: number) => {
|
||||||
if (toIndex === undefined) return;
|
if (toIndex === undefined) return;
|
||||||
if (!isArr(field.value)) return;
|
if (!isArr(field.value)) return;
|
||||||
|
@ -306,6 +306,7 @@ export const Table: any = observer(
|
|||||||
const toIndex = e.over?.data.current?.sortable?.index;
|
const toIndex = e.over?.data.current?.sortable?.index;
|
||||||
const from = field.value[fromIndex] || e.active;
|
const from = field.value[fromIndex] || e.active;
|
||||||
const to = field.value[toIndex] || e.over;
|
const to = field.value[toIndex] || e.over;
|
||||||
|
field.move(fromIndex, toIndex);
|
||||||
onRowDragEnd({ from, to });
|
onRowDragEnd({ from, to });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user