question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nodes are not draggable when integrated with `dagre` in v10

See original GitHub issue

Describe the Bug

Discussed in this thread and creating an issue to track it.

I created an example with v9 that’s integrated with dagre for custom layout. It works pretty well (see the example here). However, after upgrading to v10, I created a similar example here but found that the dragging feature is not working. The only difference btw these two examples is that I split elements into nodes and edges due to the new API changes. The rest code should be pretty much the same. It might be something related to the new API onNodesChange and onEdgesChange, but I can’t figure out the exact reason. Do you have ideas on this?

I understand that we can work around the issue if we call the layout calculation once as suggested here. However, in our app we will add nodes dynamically. Based on @moklick’s suggestion https://github.com/wbkd/react-flow/issues/1113#issuecomment-829461998, it seems that we should re-calculate the layout whenever a new node is added. That’s why I implemented this way in v9 and it works like a charm. I’m wondering if someone can shed a light on how to make it work in v10 as well.

Your Example Website or App

https://stackblitz.com/edit/react-ts-qfwtky?file=App.tsx

Steps to Reproduce the Bug or Issue

  1. Go to this Stackblitz example.
  2. Try to drag any node in the graph.
  3. You’ll find out that nodes are not draggable.

Expected behavior

As a user, I expected all nodes in the graph are draggable by default.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 98.0.4758

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
OrhanTozancommented, Feb 25, 2022

If you want the same behaviour as v9, replace nodes={} and edges={} with defaultNodes and defaultEdges.

0reactions
sushantdhimancommented, Mar 18, 2022

I am facing exactly same issue (I am using elkjs for layouting), I opted for defaultNodes/ defaultEdges which seems to be working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

is Dynamic auto layouting using dagre possible? #1113 - GitHub
I am building a node-based editor with react-flow, my requirement is ... Nodes are not draggable when integrated with dagre in v10 #1930....
Read more >
Layouting bug in react-flow-renderer v10 - Stack Overflow
I am trying to arrange nodes on a graph with the help of dagre library for layouting & Vite js as a build...
Read more >
Drag and Drop Example - React Flow
A drag and drop user interface is very common for node-based workflow editors. The drag and drop behaviour outside of the React Flow...
Read more >
react-flow-renderer - npm
A highly customizable React component for building interactive graphs and node-based editors. Getting Started | Documentation | ...
Read more >
React Flow 10 Release - webkid blog
React Flow now supports sub flows and groups, works on touch devices and comes with a lot of useful hooks like useReactFlow, useViewport...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found