-
Notifications
You must be signed in to change notification settings - Fork 231
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
Error when attempting to drag custom nodes #338
Comments
Hi @terahn are you able to provide a step by step where you replicate the issue in the official library live playground? I also have a custom node integration there and it does not break while drag&dropping? Maybe something specific to your implementation? Would it be a possibility for you to share a repo with the code? Cheers! |
After more investigation I finally figured out what was causing the problem. My CustomNode component's outer div had a className of 'node' and I guess this was confusing d3 into thinking there was an additional node for each real node (since the outermost <div className="node">
<div
className="node-img"
style={{ backgroundImage: `url(${artist.img})` }}
/>
<div className="node-tooltip">
<div className="tooltip-arrow" />
<div className="node-label">{artist.id}</div>
</div>
</div> Simply changing my CustomNode's class name to something other than 'node' solved this problem. I feel like this mistake could easily be made by others, so maybe it would be worth trying to find a way to prevent this from happening. |
I think from the library perspective I can try and make the class name more specific, it's a design mistake on my end. But removing it now it would be a breaking change. On the client (developer) side, you can take the same precautions when writing your components and use something like CSS modules to make your CSS atomic and avoid clash naming with the vendor libs or other parts of your application. |
Good suggestion! I'll have to look into that 👍 |
When using custom nodes, attempting to drag any node results in an error.
This seems to happen because the
nodeList
contains 2 entries for each node (one containing the actual node information and another blank node), and the wrong one is being selected. This results in the state lookup for the specific node returning undefined.My graph configuration:
The text was updated successfully, but these errors were encountered: