fix: error in tree table dragging and sorting (#2476)

This commit is contained in:
katherinehhh 2023-08-17 18:05:12 +08:00 committed by GitHub
parent 9dc08277e1
commit 3fc3d34aa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -304,10 +304,9 @@ export const Table: any = observer(
} }
const fromIndex = e.active?.data.current?.sortable?.index; const fromIndex = e.active?.data.current?.sortable?.index;
const toIndex = e.over?.data.current?.sortable?.index; const toIndex = e.over?.data.current?.sortable?.index;
const from = field.value[fromIndex]; const from = field.value[fromIndex] || e.active;
const to = field.value[toIndex]; const to = field.value[toIndex] || e.over;
field.move(fromIndex, toIndex); onRowDragEnd({ from, to });
onRowDragEnd({ fromIndex, toIndex, from, to });
}} }}
> >
<tbody {...props} /> <tbody {...props} />