-
IntroductionGood morning from Spain, my name is Mario and I'm facing an issue after updating @joint/core from 4.1.3 to 4.2.1. // 4.1.3 "node_modules/@joint/core": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/@joint/core/-/core-4.1.3.tgz",
"integrity": "sha512-X769blCoVxtx6NNm/cbHDXDOa+Gt7eZwrJMLnqJw8c5NkjmcYWCY1kA3ep8RfRRVG76f3QLNd9a8Q/aItI/WWw==",
"license": "MPL-2.0"
}
// 4.2.1 "node_modules/@joint/core": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/@joint/core/-/core-4.2.1.tgz",
"integrity": "sha512-E8dt0a2hwA/GI9bQ3gsYGkIE2qrY/niqBafqUBnS41VTIS9sudsPhMI7gu7TaczuFp3bx2qywWPTieUzHQdTOA==",
"license": "MPL-2.0"
}
The issue is that graph.getConnectedLinks is not returning anything in 4.2.1, whereas in 4.1.3 it correctly returns all connected links. My code: function analyzeCascadeDeleteElementInternal(
element: dia.Element,
graph: dia.Graph,
context: ICascadeContext
): void {
// Get all links connected to the element
const connectedLinks = graph.getConnectedLinks(element);
// eslint-disable-next-line no-debugger
debugger;
}Inside jointjs => getConnectedLinks there are two main internal functions: addOutbounds and addInbounds. For example: addOutbounds (the other one is equivalent for this comparison): Version 4.1.3 util.forIn(graph.getOutboundEdges(model.id), function(_, edge) {In this case, graph.getOutboundEdges(model.id) returns the expected information, and graph has properties such as _nodes and _out:
Version 4.2.1 forIn(graph.topologyIndex.getOutboundEdges(model.id), function (_, edge) {In this case, graph.topologyIndex.getOutboundEdges(model.id) returns nothing, and graph.topologyIndex does not have properties such as _nodes or _out. I've compared the documentation and I haven’t found anything about topologyIndex or any note about a changed behaviour of getConnectedLinks. I haven't had time to dive deeper into the source code, so maybe this is not actually a bug and there is a simple solution that I’m missing (like refreshing the elements list index or something). P.S.: I’ve read and compared the section about getConnectedLinks and it looks the same in both versions: 4.2.1 → https://docs.jointjs.com/api/dia/Graph/ 4.1.3 → https://docs.jointjs.com/4.1/api/dia/Graph/ Main stack libraries: Thanks in advance! Steps to reproduceNo response Restrictions & ConstraintsNo response Does your question relate to JointJS or JointJS+. Select both if applicable.JointJS |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
Hi Mario, could you please provide steps to reproduce the issue. It seems to work as expected in common scenarios. |
Beta Was this translation helpful? Give feedback.
-
|
Hi Roman, I have just solve the issue. I found that graph.getConnectedLinks(element) returns an empty array when using JointJS with React only in development mode (StrictMode enabled). Root cause: I had two separate useEffect hooks—one for Paper initialization and another for rendering shapes—the cleanup function of the first effect calls graph.clear(), which empties the internal topologyIndex (new in v4.2.1). In StrictMode, React re-runs effects, but if the second effect's dependencies haven't changed, it won't re-execute, leaving the graph with an empty topologyIndex due to the first useEffect cleanup function that gets executed. Thank you so much for your time! |
Beta Was this translation helpful? Give feedback.



Hi Roman, I have just solve the issue.
I found that graph.getConnectedLinks(element) returns an empty array when using JointJS with React only in development mode (StrictMode enabled).
Root cause: I had two separate useEffect hooks—one for Paper initialization and another for rendering shapes—the cleanup function of the first effect calls graph.clear(), which empties the internal topologyIndex (new in v4.2.1). In StrictMode, React re-runs effects, but if the second effect's dependencies haven't changed, it won't re-execute, leaving the graph with an empty topologyIndex due to the first useEffect cleanup function that gets executed.
Thank you so much for your time!