Skip to content

Table drag and drop: dropping below the last row makes the row disappear #10463

Description

@meesvandongen

Provide a general summary of the issue here

Dropping a row past the last row of a Table that already has rows makes the dragged row disappear. onInsert/onReorder receive a generated key (e.g. react-aria-27) as e.target.key instead of a row key.

🤔 Expected Behavior?

e.target.key should be the key of the last row, with dropPosition: 'after', so the item is inserted at the end of the list.

😯 Current Behavior

When the pointer moves downward past the last row, e.target.key is the 's auto-generated collection key:

{"items":[{"kind":"text","types":{}}],"dropOperation":"move",
 "target":{"type":"item","key":"react-aria-27","dropPosition":"after"}}

vs. a working drop between rows, where the key is 2. useListData.insertAfter is a no-op for an unknown key, so nothing is inserted — but onDragEnd fires with dropOperation: 'move' and isInternal: false, so the item is removed from the source list and disappears entirely. No error is thrown.

💁 Possible Solution

TreeDropTargetDelegate.getPotentialTargets walks up the target row's parent chain to offer "after the parent" as an alternative drop target. It doesn't check that the ancestor is a row, so for a flat table the last row's parent — the <TableBody> node — becomes a second potential target, and downward movement escalates to it in selectTarget. Only pushing ancestor targets for nodes of type 'item' fixes it.

🔦 Context

Drag and drop between two tables silently loses data — the user sees the row vanish from both lists with no error.

🖥️ Steps to Reproduce

Open the "Multiple positions" example on https://react-spectrum.adobe.com/react-aria/dnd.html and switch to the Table variant.
Drag a row from the first table over the second table.
Move the pointer below the last row.
Drop. The row disappears from both tables.

chrome_znza1IxWUV.mp4

Version

rac 1.20

What browsers are you seeing the problem on?

Chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions