-
Notifications
You must be signed in to change notification settings - Fork 138
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
Create a VSCode Demo #179
Create a VSCode Demo #179
Conversation
Ok, I've got it working with this branch. I now need to think about the names of these methods, and what to make public API. I am considering exposing what will be the new parent for the dragging node on the tree. This would give users more flexibility for when to highlight nodes and when not to. Maybe these methods would help:
Then the highlight logic in the node renderer would be:
Demo Working Now In this Branch CleanShot.2023-09-01.at.09.41.05.mp4 |
Hello @jameskerr, I've been closely monitoring this PR for the past couple of weeks and would like to kindly inquire about its current status. The feature it introduces is truly fantastic! If this PR has been deprioritised, please don't hesitate to reach out if you require any external assistance to expedite its progress. |
@GeorgeGkas thank you for reaching out. Other things came up, but now that you've commented here, I can push this over the finish line soon. |
Hi @jameskerr, we're using react-arborist for exactly this purpose, so this looks really useful. Thanks! One VS Code behaviour we'd like to mimic is that for leaf nodes, ⌘+↓ and double-clicking should open the file and focus the editor. We have the Do you think react-arborist could potentially support this use case? Perhaps this would be possible by adding an optional second argument to the |
@haines yes we should be able to support that with a custom keyboard shortcut solution. Everyone want's different keyboard shortcuts for the tree, so there is a plan to make these configurable. |
Hey you all, give this version a try and tell me if there are any problems. |
Thank you so much for this @jameskerr . Will try and report back soon. |
Hello @jameskerr. I have reviewed the introduced functionality, and it seems good to me. However, there is one more requirement to be met. Currently there is no way to find out if an element completed the drop.
Then we can register the handler on |
This works well for us, although it was slightly awkward to detect the case when the drag destination is the root. We ended up with this as our function to determine if the node should be highlighted: function highlightDragDestination(
tree: TreeApi<NodeData>,
node: NodeApi<NodeData>,
): boolean {
if (
tree.dragDestinationParent === null &&
tree.dragDestinationIndex === null
) {
return false;
}
const parent = tree.dragDestinationParent ?? tree.root;
return (
parent.isAncestorOf(node) &&
tree.dragNodes.some((dragNode) => dragNode.parent?.id !== parent.id)
);
}``` |
Add the following methods to the tree api.
get dragNode() {
return this.get(this.state.nodes.drag.id);
}
get dragDestinationParent() {
return this.get(this.state.nodes.drag.destinationParentId);
}
get dragDestinationIndex() {
return this.state.nodes.drag.destinationIndex;
}
The demo is not finished yet, but these three new methods should unblock people from doing VSCode style dragging and dropping.