Tree component for React with ability to drag-and-drop items throughout the tree. Based on an example from dnd-kit (https://github.com/clauderic/dnd-kit).
MIT License
81
stars
22
forks
source link
Feature Request: Callback for canHaveChildren for Root #24
I would like to be able to restrict the movement of items within the tree conditionally. If a condition is met, I want elements to not be able to change their parent and only be sorted (i.e. their indices changed) within their current parent. While part of this can be accomplished using canHaveChildren, one can still always move items to the root (simply adding a top-level item does not fix the problem). While I can disable the actual movement in onItemsChanged, the preview is still shown at the top level. Ideally, I would like to have a callback to determine if a specific drag is valid and only then show the preview in that new position, otherwise the preview would remain in its previous position. If that is too difficult, is it possible to add a callback to SortableTree, which has the same effect as canHaveChildren but for the root?
I would like to be able to restrict the movement of items within the tree conditionally. If a condition is met, I want elements to not be able to change their parent and only be sorted (i.e. their indices changed) within their current parent. While part of this can be accomplished using canHaveChildren, one can still always move items to the root (simply adding a top-level item does not fix the problem). While I can disable the actual movement in onItemsChanged, the preview is still shown at the top level. Ideally, I would like to have a callback to determine if a specific drag is valid and only then show the preview in that new position, otherwise the preview would remain in its previous position. If that is too difficult, is it possible to add a callback to SortableTree, which has the same effect as canHaveChildren but for the root?