-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(RAC): Tree drag and drop #7692
base: main
Are you sure you want to change the base?
Conversation
… if a parent node can be dropped into its children
Thanks for the PR! I'm going to be taking a closer look when I have some time soon, just wanted to leave an update. |
13b0645
to
7c81ea2
Compare
thanks, have you managed to carve out some time to look at this? |
Sorry for the delay, we've been busy with the latest release! I just pushed a few small updates and a story that has DnD working in RAC Tree. I still need to debug RSP TreeView and fix some merge conflicts. The state management in the story should get simplified once we merge #7854. |
Pushed a few changes so it should be in a decent state to test out. Some things to note:
|
@@ -234,10 +235,29 @@ export function useTreeData<T extends object>(options: TreeOptions<T>): TreeData | |||
} | |||
} | |||
|
|||
function getDescendantKeys(node?: TreeNode<T>): Key[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to have node be optional? can we make it required?
if (!node) { | ||
return descendantKeys; | ||
} | ||
function recurse(currentNode: TreeNode<T>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the traversal order matter? preorder, in order, postorder
should descendantKeys be a Set if it doesn't matter?
disabledKeys: state.selectionManager.disabledKeys, | ||
disabledBehavior: state.selectionManager.disabledBehavior, | ||
layout: 'stack', | ||
direction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that Table in RAC doesn't specify direction
is that a bug? or what does this affect?
I'm looking to get some feedback on this PR to add drag and drop to the Tree.
I am really really new to this codebase, and there are probably a ton of things I've not understood and have messed up
I've mainly just copied the logic from the listbox and applied it to the tree component.
There's a storybook story which I've added at http://localhost:9003/?path=/story/treeview--tree-example-dynamic-drag-n-drop&providerSwitcher-express=false&strict=true
Some things that would be great to get some feedback/help on are:
I'm unclear as to whether the dragAndDropHooks should be created by the user each time (e.g. in the story). Some things i can see being useful, but it feels like the reorder function shouldn't have to be implemented here. Is there a better place to put this?
Re-ordering works, but at some point it stops working. I can't seem to find a repeatable pattern of drag / drops to consistently replicate this though.
In storybook the hot reload gives an error:

Although I've added the keyboard code - I've not yet tested that - was hoping to get the other issues ironed out first.
The way I've implemented the drop insert indicator causes the tree items to move which in turn can cause the drop to switch from before to after. The droppable listbox story renders items with a gap in between but I'm not sure if that is what is wanted in a tree view.