Fixed dropping into empty group (#15066)
This PR fixes a bug when dropping into an empty group with the recent refactor of the drag and drop logic in #14743
This commit is contained in:
+32
-5
@@ -49,17 +49,44 @@ export const processGroupDragOperation = ({
|
||||
recordIdsByGroupFamilyState(destinationGroupId),
|
||||
) as string[];
|
||||
|
||||
const recordsWithPosition = extractRecordPositions(
|
||||
destinationRecordIds,
|
||||
snapshot,
|
||||
);
|
||||
|
||||
const draggedRecordId = result.draggableId;
|
||||
|
||||
const dragOperationType = getDragOperationType({
|
||||
draggedRecordId,
|
||||
selectedRecordIds,
|
||||
});
|
||||
|
||||
const targetGroupIsEmpty = destinationRecordIds.length === 0;
|
||||
|
||||
if (targetGroupIsEmpty) {
|
||||
if (dragOperationType === 'single') {
|
||||
onUpdateRecord(
|
||||
{
|
||||
recordId: draggedRecordId,
|
||||
position: 1,
|
||||
},
|
||||
recordGroup.value,
|
||||
);
|
||||
} else {
|
||||
for (const [index, selectedRecordId] of selectedRecordIds.entries()) {
|
||||
onUpdateRecord(
|
||||
{
|
||||
recordId: selectedRecordId,
|
||||
position: index + 1,
|
||||
},
|
||||
recordGroup.value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const recordsWithPosition = extractRecordPositions(
|
||||
destinationRecordIds,
|
||||
snapshot,
|
||||
);
|
||||
|
||||
const destinationIndex = result.destination.index;
|
||||
|
||||
const isDroppedAfterList = destinationIndex >= recordsWithPosition.length;
|
||||
|
||||
Reference in New Issue
Block a user