adobe / adobe/react-spectrum

Cannot drag a item in a virtualized component if the virtualizer removes the item from the DOM

Open
#5,336 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

Description

### Discussed in https://github.com/adobe/react-spectrum/discussions/5320

Originally posted by **hipstersmoothie** October 27, 2023
I have a virtualized draggable listbox and it mostly work.

One thing that doesn't is dragging things from the start of the list to the end of the list. If the dragged item gets unmounted while the drag is happening, the useDraggableItem calls it onDragEnd and the drag operation won't work.

Is there any guidance on this?

Looking at the code it looks like useDrag doesn't really depend on the original element still being mounted.

The issue lies in the code below

```
// If the dragged element is removed from the DOM via onDrop, onDragEnd won't fire: https://bugzilla.mozilla.org/show_bug.cgi?id=460801
// In this case, we need to manually call onDragEnd on cleanup
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.