minop1205 / react-dnd-treeview

A draggable / droppable React-based treeview component. You can use render props to create each node freely.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expose tree index at placeholder position

chris-oms opened this issue · comments

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

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

image

@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} />}