Skip to content

Commit

Permalink
Merge pull request #5127 from mathbraga/bug/5059_fix_external_connect…
Browse files Browse the repository at this point in the history
…ion_after_updating_edges

Bug/5059 fix external connection after updating edges
  • Loading branch information
sidharthv96 authored Jan 23, 2024
2 parents 7b62466 + 679f77d commit 1612d3f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cypress/integration/rendering/flowchart-v2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,25 @@ A ~~~ B
);
});

it('5059: Should render when subgraph contains only subgraphs, has link to outside and itself is part of a link', () => {
imgSnapshotTest(
`flowchart
subgraph Main
subgraph Child1
Node1
Node2
end
subgraph Child2
Node3
Node4
end
end
Main --> Out1
Child2 --> Out2`
);
});

describe('Markdown strings flowchart (#4220)', () => {
describe('html labels', () => {
it('With styling and classes', () => {
Expand Down
14 changes: 14 additions & 0 deletions packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ export const adjustClustersAndEdges = (graph, depth) => {
}
});

for (let id of Object.keys(clusterDb)) {
const nonClusterChild = clusterDb[id].id;
const parent = graph.parent(nonClusterChild);

// Change replacement node of id to parent of current replacement node if valid
if (parent !== id && clusterDb[parent] && !clusterDb[parent].externalConnections) {
clusterDb[id].id = parent;
}
}

// For clusters with incoming and/or outgoing edges translate those edges to a real node
// in the cluster in order to fake the edge
graph.edges().forEach(function (e) {
Expand Down Expand Up @@ -307,9 +317,13 @@ export const adjustClustersAndEdges = (graph, depth) => {
w = getAnchorId(e.w);
graph.removeEdge(e.v, e.w, e.name);
if (v !== e.v) {
const parent = graph.parent(v);
clusterDb[parent].externalConnections = true;
edge.fromCluster = e.v;
}
if (w !== e.w) {
const parent = graph.parent(w);
clusterDb[parent].externalConnections = true;
edge.toCluster = e.w;
}
log.warn('Fix Replacing with XXX', v, w, e.name);
Expand Down

0 comments on commit 1612d3f

Please sign in to comment.