[BUG] Current DragAndDrop API is unworkable
🐛 Describe the bug
The DragAndDrop API in its current form is not possible to use.
⚠️ Current behavior
Functions have dubious naming:
-
DragContainerandDropContainersound like counterparts but they are not.DragTargetis the current counterpart forDropContainer. Try to use them by their current naming and it doesn't even layout correctly -DragContainerdoes something to break the component being added to layouts. -
DragTargetmakes no sense because "target" refers to where you are dropping the thing. Usually we refer to the place where you start the operation as the "drag source". - What
DragContaineractually appears to be for is... just drawing the overlay? So maybe a good name would beDragAndDropOverlayor something to that effect.
Next issue is, the MIME type system isn't flexible enough to actually use, real data transfer pretty much lets you have anything you want.
Last issue is major, the current API requires the draggable data to be constructed in order to declare the drag target. You don't want to eagerly instantiate the draggable data for every item in the application. That's how you make an application run out of memory. Instead, there should be some kind of callback to create the draggable data which would be one of the parameters for the drag source.
I also expected some kind of method for consuming the thing when it was dropped but I couldn't find it at all. Actually I'd expect two callbacks. One for the drop target to inform it that some data has been dropped, and another for the drag source to inform it that the data has been dragged out (at the time when the drop happens, though, not as soon as it's picked up, otherwise when the user cancels the drag by hitting Escape, they will find out they have nothing left).
So all up I don't think this library is usable to implement drag and drop, but it does give good, solid examples of how the different bits have to be fit together to make drag and drop work, which is helpful anyway.
✔️ Expected behavior
The library can be used without hassle, the API makes sense and things generally work.
🪜 Steps to reproduce
📷 Screenshots
📱 Tech info
- Name of the library:
- Library/sample version:
- Device/emulator version/model:
- OS:
Hi @hakanai, thanks for the feedback. The API is still under development, so we'll keep these ideas in mind as we work on future releases.