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

add relativeIndex to onDrop callback #200

Closed kristian-puccio closed 1 year ago

kristian-puccio commented 1 year ago

This adds the relativeIndex property to the onDrop callback. Closes #196

minop1205 commented 1 year ago

Thank you!

I think the pull request certainly solves the problem in #196, but I think I need to add support for dragging from outside the tree as well.

Also, although it is an issue with the original code, it would be better to have some common code when passing indexes to onDrop and canDrop, and I felt the need to do some refactoring in this area.

Therefore, I'm very sorry, but I will close this PR for now and release a new one with the corrected problem soon.

kristian-puccio commented 1 year ago

@minop1205 Fair enough, I think your solution does sound better. One issue I found with having common code with onDrop and canDrop is that the placeholderIndex isn't ready when canDrop is called. At least I think...