React-sortable-tree: Does Ver 0.1.20 support DND between 2 react-sortable-tree ? If yes, how ?

Created on 13 Jul 2017  路  5Comments  路  Source: frontend-collective/react-sortable-tree

Hi I see the approach you have done in the example of externalNodeExample, and I just tried to implement DND between 2 react sortable trees. But I cannot find a way to pass the "addItem" and "dropCancelled" functions into the second tree. Could you please offer some suggestions ? Thanks in advance !!!

Most helpful comment

I think that would be an interesting feature to add. Good suggestion.

All 5 comments

Since I'm the guy who wrote PR #113 for adding in external nodes, here's my two cents:

The current implementation for the tree component itself doesn't use the props for the _addItem_ and _dropCancelled_ methods of the externally wrapped node, so passing them in won't allow for control of any tree behavior directly, since only the externally wrapped node makes use of them to communicate to the tree.

What _*may_ work for creating drag and drop between two trees is if you were to wrap the tree's NodeContentRenderer on L73 with additionally perhaps the API's external node wrapper. Kind of like how this issue #427 on the main React-dnd repository recommends how to wrap a component with more than one drag source. This would require passing in a custom NodeContentRenderer prop to the main tree component as well.

However, if this does work, what won't happen automatically is the removal of the first node from the dragged-from tree after dropping in of the node in the second tree, that's something you'd need to anticipate, if that's what you are hoping to occur as well.

In all likelihood, I don't see this happening cleanly without another PR focused on enabling tree-to-tree communication, as was my experience with adding in the external nodes functionality.

Hope this helps.

_*NOTE: this is purely conjecture and not at all tested or verified._

Thanks for the thorough explanation ! Will you guys consider adding this feature in near future. Since I would say that will absolutly make react-sortable-tree even greater ! @stephenc222

I think that would be an interesting feature to add. Good suggestion.

Does anybody have examples of working code with moving nodes across 2 react sortable trees? (e.g. using NodeContentRenderer as it was mentioned above).
Thanks!

Works now as of version 1.0.0. See the storybook linked in the readme for examples.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kaueDM picture kaueDM  路  3Comments

bigjujube picture bigjujube  路  4Comments

Suremotoo picture Suremotoo  路  4Comments

mhiggs picture mhiggs  路  3Comments

xmhscratch picture xmhscratch  路  5Comments