minop1205 / react-dnd-treeview

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

Expose tree index at placeholder position #179

Open chris-oms opened 1 year ago

chris-oms commented 1 year ago

Is your feature request related to a problem? Please describe. When dragging from one tree to another, I can't currently find a way to drop the external node into the location shown by the placeholder (as demo'd in the "Manual sort with placeholder" example). If the index of the tree item before the placeholder was somehow exposed, I could then calculate the position required to push the new node item into the tree.

Describe the solution you'd like Expose the index of the external tree item to the placeholder component callback

Describe alternatives you've considered I cannot find another way of doing what I'm after. Any solution that would allow the correct position for the external node to be placed would be fine - it doesn't have to be the one I've suggested

minop1205 commented 1 year ago

@chris-oms Can't use options.relativeIndex ?

image

chris-oms commented 1 year ago

@minop1205 I get Property 'relativeIndex' does not exist on type 'PlaceholderRenderParams'

Looks like the only property of options that is passed through to placeholderRender is depth, or am I missing something?

placeholderRender={(node, { depth }) => <OrderDividerPlaceholder depth={depth} />}