minop1205 / react-dnd-treeview

A draggable / droppable React-based treeview component. You can use render props to create each node freely.
MIT License
531 stars 71 forks source link

fix: hide placeholder when there are no targets #222

Closed nuragic closed 6 months ago

nuragic commented 9 months ago

Hi! First of all, thanks so much for for this library, it's really awesome, tremendous work!

I hope this proposal makes sense. It's aimed to improve the UX of the drag and drop in a specific scenario.

Problem

When using the custom placeholder, there is a case in which you still see it rendered but you can't actually drop the item being dragged. That happens when you try to drag any item at the very top or bottom of the tree. If your cursor goes outside the bounds of the container, the placeholder is still there, hinting that the item will be dropped right there, but in reality if you drop it nothing happens... it's misleading because the placeholder is there, but the item cannot be dropped.

https://github.com/minop1205/react-dnd-treeview/assets/1586378/ffab0175-fca3-4988-aecf-33d67c6f7030

Solution

What I'm proposing is just to hide the placeholder when there are no targets. I don't know if this is the correct solution technically speaking but I believe it's the correct one in terms of UX. Happy to change the implementation as you see fit. Any feedback also very welcome. Thanks!

https://github.com/minop1205/react-dnd-treeview/assets/1586378/d409892c-e888-4d25-b3d1-feea666f4b1c

DavidRnR commented 9 months ago

Thank you @nuragic! I've reported this issue a few weeks ago.

https://github.com/minop1205/react-dnd-treeview/issues/220

Seems working well :)

minop1205 commented 6 months ago

@nuragic I think this is a simple and clear way to address the issue.

Thank you for your cooperation! And sorry for the late reaction.

minop1205 commented 6 months ago

100

nuragic commented 6 months ago

Thank you!