lukasbach / react-complex-tree

Unopinionated Accessible Tree Component with Multi-Select and Drag-And-Drop
https://rct.lukasbach.com
MIT License
952 stars 77 forks source link

on drag and drop node copy feature not move required #238

Closed AbhishekupadhyayDemo closed 1 year ago

AbhishekupadhyayDemo commented 1 year ago

I want to drag a node from tree one to tree two by copying the node tree two not moving it

lukasbach commented 1 year ago

Hey, thanks for your report!

You can already do that with some additional custom handling, by using a controlled environment. You will need to provide handlers for the view state of the trees yourself, but can customize what happens in the onDrop handler. There you could implement handling that duplicates the items that are being dropped and adds them to the new target item without removing them from their source item.

AbhishekupadhyayDemo commented 1 year ago

Hi, thanks for the fast reply, Do You have any example for that it would be a great help because i am not able to do that i tried

lukasbach commented 1 year ago

Sorry for the late reply, but no I don't have any specific examples for that. If you want to understand how the drop logic for controlled environments can be customized in general, the uncontrolled environment component is just a wrapper around the controlled environment, so maybe its implementation can help in understanding what can be done: https://github.com/lukasbach/react-complex-tree/blob/main/packages/core/src/uncontrolledEnvironment/UncontrolledTreeEnvironment.tsx