Drag stop listeners aren't working if multiple nodes are moved
See original GitHub issueIssue
If more than one node is selected with the “click to multi select” feature (https://github.com/wbkd/react-flow/issues/609, https://github.com/wbkd/react-flow/pull/663), then there seems to be no handler that will work, if more than one node is dragged.
Reproducing the issue
- Open the overview example
- Enable or set
multiSelectionKeyCode(default isMeta) Meta + Clicktwo nodes- Drag to change both node positions
Observation
onNodeDragStop(event, node) will fire, but only contain a single node instead of a list of all nodes.

onSelectionDragStop(event, nodes) doesn’t fire. Based on this comment it seems to be the expected behavior, and “selection” is the blue box, but not multiple elements that are selected per click.
Potential solutions
It might be that I’m missing something here. So, helping me out, could be a solution 😃 If that’s not the case:
onSelectionDragStopcould fire with a list of moved nodes regardless if the multiselection was done withmultiSelectionKeyCodeor with a rectangleonNodeDragStopcould be called with a list of nodes instead of a single node, if more than one node was moved
Info
- Using
react-flowin version9.6.1 - Similar to https://github.com/wbkd/react-flow/issues/858
- Relevant comment https://github.com/wbkd/react-flow/issues/1006#issuecomment-799758872
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Event listener on parent node is triggering on all children ...
I solved it, it wasn't working because I was setting the current element as this.elem = e.target instead of this.elem = e.currentTarget ....
Read more >Drag'n'Drop with mouse events - The Modern JavaScript Tutorial
Drag 'n'Drop is a great interface solution. Taking something and dragging and dropping it is a clear and simple way to do many...
Read more >HTML Drag and Drop API - MDN Web Docs
HTML drag-and-drop uses the DOM event model and drag events inherited from mouse events . A typical drag operation begins when a user...
Read more >Drag Overlay - dnd-kit – Documentation
If your item needs to move from one container to another while dragging, ... render the <DragOverlay> component, drop animations will not work....
Read more >Mind map - Miro Help Center
All nodes are automatically aligned but you can select and drag the ... (for Mac) if you'd like to move the node instead...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Another workaround, using the internal state of nodes, so far seems to work with single and multi selection drag movement.
We are working on a next release #2152. We dropped react-draggable and rewrote the dragging logic. We are now passing a third parameter
nodestoonNodeDragStart,onNodeDragandonNodeDragStopthat includes all selected nodes. You can check out the next version withnpm install react-flow-renderer@next.@Zelenya7 the new version should solve your issue, otherwise you can filter your local nodes array
const selectedNodes = nodes.filter(n => n.selected). The nodes receiveselectedas an attribute.