fix: render continuation edges exiting compound nodes (SPLIT, CHOICE)
The cross-root boundary check in createElkEdges() was too aggressive, skipping all edges where source and target have different ELK roots. Compound nodes are their own ELK roots, so valid continuation edges from the last child inside a compound to the next sibling were lost. Now allows edges when nodes share a common grandparent or when one node exits/enters a compound boundary. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -309,8 +309,22 @@ public class ElkDiagramRenderer implements DiagramRenderer {
|
|||||||
if (ctx.compoundNodeIds.contains(re.getSource()) && isDescendantOf(targetElk, sourceElk)) {
|
if (ctx.compoundNodeIds.contains(re.getSource()) && isDescendantOf(targetElk, sourceElk)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Skip edges that cross ELK root boundaries
|
// Skip edges that cross ELK root boundaries — but allow continuation
|
||||||
if (getElkRoot(sourceElk) != getElkRoot(targetElk)) continue;
|
// edges that exit a compound (source inside compound, target outside)
|
||||||
|
if (getElkRoot(sourceElk) != getElkRoot(targetElk)) {
|
||||||
|
// Allow if source and target share the same grandparent (main root)
|
||||||
|
// i.e., one is inside a compound and the other is a sibling
|
||||||
|
ElkNode sourceRoot = getElkRoot(sourceElk);
|
||||||
|
ElkNode targetRoot = getElkRoot(targetElk);
|
||||||
|
boolean sameGrandparent = sourceRoot.getParent() != null
|
||||||
|
&& targetRoot.getParent() != null
|
||||||
|
&& sourceRoot.getParent() == targetRoot.getParent();
|
||||||
|
boolean sourceExitsCompound = sourceRoot.getParent() != null
|
||||||
|
&& targetRoot == sourceRoot.getParent();
|
||||||
|
boolean targetExitsCompound = targetRoot.getParent() != null
|
||||||
|
&& sourceRoot == targetRoot.getParent();
|
||||||
|
if (!sameGrandparent && !sourceExitsCompound && !targetExitsCompound) continue;
|
||||||
|
}
|
||||||
|
|
||||||
ElkEdge elkEdge = ctx.factory.createElkEdge();
|
ElkEdge elkEdge = ctx.factory.createElkEdge();
|
||||||
elkEdge.setContainingNode(findCommonParent(sourceElk, targetElk));
|
elkEdge.setContainingNode(findCommonParent(sourceElk, targetElk));
|
||||||
|
|||||||
Reference in New Issue
Block a user