uber / react-digraph

A library for creating directed graph editors
MIT License
2.62k stars 268 forks source link

Supporting the selection of multiple nodes? #178

Open kennethbruskiewicz opened 4 years ago

kennethbruskiewicz commented 4 years ago

Is your feature request related to a problem? Please describe. In my application, each node represents a table of data. When several tables of data are selected, the view that represents them needs to change from just a flat list of items, into a representation that compares the contents of the two tables. This requires firing off multiple selection events, ideally representing that multiple nodes are selected in the GraphView.

Describe the solution you'd like When I click on a node after selecting a different node, that node is also selected. When I click on this newly selected node again, the node is deselected.

Describe alternatives you've considered It looks like the GraphView only supports one selectedNodeObj value for its rendering. Allowing for multiple selected nodes would involve rewriting this component to handle an array of Nodes?

ajbogh commented 4 years ago

Thanks for the issue @kbruskiewicz. We are planning on adding mutliple selection to enhance the copy/paste functionality. I believe that feature will solve your issue. We do not have a current timeline for this feature though.

tony-garcia commented 4 years ago

@ajbogh There's a copy/paste functionality? Where is that documented?

ajbogh commented 4 years ago

The README lists the two functions:

onCopySelected?: () => void;
onPasteSelected?: () => void;

The onSelectNode function has to be activated first with a node, then the onCopySelected function will be activated by a Ctrl/Cmd-C and onPasteSelected with Ctrl/Cmd-V. It's the developer's responsibility to know what to do with copied and pasted nodes.

tony-garcia commented 4 years ago

@ajbogh thanks. With regard to multiple select -- will that also enable us to drag multiple nodes?

ajbogh commented 4 years ago

@tony-garcia That is certainly the hope, however we will need to review the usability of the system and document the current key combinations to determine if that is the best way to go forward - working within the current keys or refactoring to allow more normal key bindings.

For instance, today the key binding for creating a new node is Shift+click, but it could be a right-click menu option instead, and shift could be used for selection of nodes. Any change like this would require a new major version.