react-dnd-treeview icon indicating copy to clipboard operation
react-dnd-treeview copied to clipboard

Drop is canceled even though placeholder is visible

Open minop1205 opened this issue 3 years ago • 3 comments

From PR below https://github.com/minop1205/react-dnd-treeview/pull/99#issue-1110578682

When Tree component is used to manual sort items, the user might drag items outside of the droppable area -- especially when trying to move it to the top or the bottom of the list. If we restrict the drop to only the tree area, we might have some weird behaviors, like rendering the placeholder somewhere, but not accepting a drop when the user releases the mouse button for example.

The default is still only allowing drop inside the tree area, but by setting cancelOnDropOutside as false we allow drops outside of the tree whenever there's a placeholder being rendered.

This is an example of the original issue:

https://user-images.githubusercontent.com/836386/150551213-773a2696-ac69-47b9-abdd-c17523f4936f.mov

minop1205 avatar Jan 26 '22 06:01 minop1205

The end option of useDrag hook is called by dropping outside the dropable area or by canceling with the ESC key, so it is necessary to distinguish between these two.

If the drop is outside the dropable area, it should be dropped at the placeholder position, and if the ESC key is pressed, the drop should be canceled.

minop1205 avatar Jan 26 '22 06:01 minop1205

Hi @minop1205 , I'm currently having this exact issue. I'm trying to drop an item with a placeholder at the top or bottom (outside of the normal droppable area) but onDrop doesn't get called. Did you manage to find a solution for this or a potential work around?

mattevans-dev avatar Jul 10 '23 13:07 mattevans-dev

Having this exact issue. Does anyone has a fix or a workaround?

uffou avatar Oct 30 '23 06:10 uffou

We have addressed this issue by not displaying placeholders when dragging over outside the dropable area.

minop1205 avatar Apr 26 '24 03:04 minop1205