mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-05 05:38:23 +08:00
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 { Button } from 'antd';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Table } from '../table-v2/Table';
|
||||
import { useAssociationFieldContext } from './hooks';
|
||||
|
||||
export const SubTable: any = observer(
|
||||
(props: any) => {
|
||||
const { field } = useAssociationFieldContext<ArrayField>();
|
||||
const { t } = useTranslation();
|
||||
const move = (fromIndex: number, toIndex: number) => {
|
||||
if (toIndex === undefined) return;
|
||||
if (!isArr(field.value)) return;
|
||||
|
@ -306,6 +306,7 @@ export const Table: any = observer(
|
||||
const toIndex = e.over?.data.current?.sortable?.index;
|
||||
const from = field.value[fromIndex] || e.active;
|
||||
const to = field.value[toIndex] || e.over;
|
||||
field.move(fromIndex, toIndex);
|
||||
onRowDragEnd({ from, to });
|
||||
}}
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user