react-arborist icon indicating copy to clipboard operation
react-arborist copied to clipboard

Adds cross-tree drag and drop functionality.

Open theearlofsandwich opened this issue 6 months ago • 0 comments
trafficstars

This PR adds the ability to drag and drop between multiple trees. It passes a reference to the drag tree on drop so you have access to what's being dropped. Works for both controlled and uncontrolled trees. I've updated the showcase demo pages to include a cross-tree demo and added some basic info into the readme.md.

There are some new tree properties, namely:

id?: string allowCrossTreeDrop?: boolean; allowCrossTreeDrag?: boolean;

and data handlers onCrossTreeAdd?: handlers.CrossTreeAddHandler<T>; onCrossTreeDelete?: handlers.CrossTreeDeleteHandler<T>;

I had to comment out the drop test code as drop now requires a reference to the initial drag tree.

Hope this code helps - it's probably not the most elegant but it does work and is reasonably comprehensive.

theearlofsandwich avatar Apr 28 '25 09:04 theearlofsandwich