Multiple draggable elements with React dnd-kit? #1313
Replies: 4 comments 2 replies
-
I'm curious about this as well. Seems odd there isn't an example around. |
Beta Was this translation helpful? Give feedback.
-
I believe the unspoken way is to abstract out a separate draggable wrapper component you create by hand that calls Some thoughts:
For 1 and 2, that might be a nice doc update. For 3, I don't know enough about this library to know if that fits with the design principles. |
Beta Was this translation helpful? Give feedback.
-
Hi there! I am having the same problem here. Till now, I was "simulating" it in such a way, that I was still dragging only one item, but on DragEnd I was moving all selected items from source list to the target. My problem here is that both, source list and target list, need to have acccess to the list of selected items, which is stored in the state, and which is not what I want to have. I would like to store selected items in dragged object (active), but with no luck till now. Any ideas, please? |
Beta Was this translation helpful? Give feedback.
-
Not sure if this is an appropriate solution or breaks anything, but I've been keeping track of a set of selected items, and when that list is non-empty, I replace the But I sorta feel like I'm abusing the API by doing this, it's probably not recommended to have multiple items with the same ID. |
Beta Was this translation helpful? Give feedback.
-
The docs don't seem to have an example for the overwhelmingly most common use case of a drag and drop library: Multiple draggable items.
useDraggable()
takes in anid
and you can't call hooks in a loop. What is the intended method for creating multiple draggable elements?Example: I have a component that renders a list of items, and I want each item to be draggable
I've searched for "dnd kit multiple draggable" but the only questions seem to be about sortable, not draggable.
Beta Was this translation helpful? Give feedback.
All reactions