Open holloway opened 1 year ago
Hey! At the moment, there are no dedicated docs for that. The gist is essentially just to implement the onDrop
handler, you can use the implementation in the uncontrolled environment for that as reference, although it is a bit verbose and messy to be honest.
When the user is dropping an item, he is hovering over an ("target") item. The target type provides details where on that item that is:
props.canDropOnFolder
is true, or it is not a folder and props.canDropOnNonFolder
is true. The expectation is that the dragged items are inserted into the hovered target item. The target variable provided to the onDrop handler is of type DraggingPositionItem
DraggingPositionBetweenItems
. The variable target.linePosition
has the value "top" or "bottom" and determines this distinction.DraggingPositionRoot
Regarding linearIndex
and childIndex
: childIndex refers to the position of an item within its parent. linearIndex refers to the overall position of the item within the entire tree, would all items be laid out in a linear manner. As an example:
The item "Black" has the childIndex 2, and the linearIndex 5.
Hope that was helpful, let me know if anything else is unclear!
When trying to implement the way its done in the uncontrolled tree environment, I'm running into the issue of items not being iterable in the initial for loop?
When trying to implement the way its done in the uncontrolled tree environment, I'm running into the issue of items not being iterable in the initial for loop?
What do you mean? Can you provide the implementation for the handler that you used and a log output of what value the items property has?
I was actually able to get it to not throw the error. Just would like an example of how to implement a simple custom onDrop handler that mimics the behavior of the uncontrolled tree.
Ah okay. One example is the actual implementation of the uncontrolled tree, but I have to admit, that it is far from simple. Unfortunately, it has a lot of corner cases that it respects at the moment, so that is all I have as an example at the moment.
Is your feature request related to a problem? Please describe.
Are there any docs on how to implement drop handlers (
<ControlledTreeEnvironment>
), specifically on how the drop target types should be interpreted and what the difference betweenlinearIndex
andchildIndex
is?