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 missing indexes to canDrop #196

Open kristian-puccio opened 1 year ago

kristian-puccio commented 1 year ago

Is your feature request related to a problem? Please describe. I want to re-enact a feature like insertDroppableFirst but rather than forcing the order post drop not allowing dropping a non droppable item before the list of droppables (ie folders).

Describe the solution you'd like If the canDrop function included all the data that onDrop has relativeIndex and destinationIndex then I would have all the data required to enforce the ordering.

Describe alternatives you've considered insertDroppableFirst but that allows the drop and then re-orders.

Additional context I believe according to the docs canDrop should have the same parameters as onDrop.

This callback takes the same parameters as the onDrop callback, but the first parameter specifies the current tree.

Oh I'll have a go at making a PR for you.

Thanks!

ann4bel commented 1 year ago

Hello! Are there any updates on this issue? I am trying to implement dragging and dropping multiple components at once (using the shift key to select components) and I would also need to access destinationIndex in canDrop so unselected components aren't able to be dropped in the middle of selected components.

jannikbertram commented 11 months ago

+1 on this. I need the destinationIndex or relativeIndex in canDrop because I'm trying to implement manual sorting where folders are always placed on top of files. I need to prevent the placeholder from showing up when you are trying to move a file on top of a folder and vice versa