minop1205 / react-dnd-treeview

A draggable / droppable React-based treeview component. You can use render props to create each node freely.
MIT License
520 stars 69 forks source link

Prevent dragging nodes to the root #104

Closed MrPrometheus closed 2 years ago

MrPrometheus commented 2 years ago

Hello, I have a tree with 1 root node, all other nodes come from 1 root node.

How can I make it so that any node below the 1st level cannot be dragged to the first level?

minop1205 commented 2 years ago

@MrPrometheus Drop availability can be controlled by the canDrop callback. https://github.com/minop1205/react-dnd-treeview#candrop-callback

Here is sample. https://codesandbox.io/s/issue-104-h8vzt0?file=/src/App.tsx

MrPrometheus commented 2 years ago

Thank you!!!