Skip to content

Commit

Permalink
fix(Canvas): Fix Edge source misplaced for containers
Browse files Browse the repository at this point in the history
In order to make room for the node's secondary label, the containers
were expanded by `10px`.

The problem comes when in vertical layout, that additional size is not
taken into account when calculating the edges since the size is only
reflected in the visualization part and not during the layout
calculation.

The solution for now is to increase the group padding just a bit to make
the secondary label to fit.

fix: #1575
  • Loading branch information
lordrip committed Oct 17, 2024
1 parent 885ce63 commit 5a09d8b
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 203 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ exports[`FlowService getFlowDiagram should return nodes and edges for a group wi
"label": "group-1234",
"parentNode": undefined,
"style": {
"padding": 60,
"padding": 65,
},
"type": "group",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export class CanvasDefaults {
static readonly DEFAULT_LAYOUT = LayoutType.DagreVertical;
static readonly DEFAULT_NODE_SHAPE = NodeShape.rect;
static readonly DEFAULT_NODE_DIAMETER = 75;
static readonly DEFAULT_GROUP_PADDING = 50;
static readonly DEFAULT_GROUP_PADDING = 65;
static readonly DEFAULT_SIDEBAR_WIDTH = 500;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class FlowService {
});

const containerId = vizNodeParam.id;
node = this.getContainer(containerId, {
node = this.getGroup(containerId, {
label: containerId,
children: children.map((child) => child.id),
parentNode: vizNodeParam.getParentNode()?.id,
Expand Down Expand Up @@ -75,7 +75,7 @@ export class FlowService {
return edges;
}

private static getContainer(
private static getGroup(
id: string,
options: { label?: string; children?: string[]; parentNode?: string; data?: CanvasNode['data'] } = {},
): CanvasNode {
Expand All @@ -88,7 +88,7 @@ export class FlowService {
parentNode: options.parentNode,
data: options.data,
style: {
padding: CanvasDefaults.DEFAULT_NODE_DIAMETER * 0.8,
padding: CanvasDefaults.DEFAULT_GROUP_PADDING,
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export const CustomGroupExpanded: FunctionComponent<CustomGroupExpandedProps> =
x={boxRef.current.x}
y={boxRef.current.y}
width={boxRef.current.width}
height={boxRef.current.height + 10}
height={boxRef.current.height}
/>
<foreignObject
data-nodelabel={label}
className="foreign-object"
x={boxRef.current.x}
y={boxRef.current.y}
width={boxRef.current.width}
height={boxRef.current.height + 10}
height={boxRef.current.height}
>
<div className={className}>
<div className="custom-group__title">
Expand Down
8 changes: 4 additions & 4 deletions packages/ui/src/tests/__snapshots__/nodes-edges.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1860,7 +1860,7 @@ exports[`Nodes and Edges should generate edges for steps with branches 1`] = `
"label": "when-1234",
"parentNode": "choice-1234",
"style": {
"padding": 60,
"padding": 65,
},
"type": "group",
},
Expand Down Expand Up @@ -2951,7 +2951,7 @@ exports[`Nodes and Edges should generate edges for steps with branches 1`] = `
"label": "otherwise-1234",
"parentNode": "choice-1234",
"style": {
"padding": 60,
"padding": 65,
},
"type": "group",
},
Expand Down Expand Up @@ -3500,7 +3500,7 @@ exports[`Nodes and Edges should generate edges for steps with branches 1`] = `
"label": "choice-1234",
"parentNode": "route-1234",
"style": {
"padding": 60,
"padding": 65,
},
"type": "group",
},
Expand Down Expand Up @@ -4906,7 +4906,7 @@ exports[`Nodes and Edges should generate edges for steps with branches 1`] = `
"label": "route-1234",
"parentNode": undefined,
"style": {
"padding": 60,
"padding": 65,
},
"type": "group",
},
Expand Down

0 comments on commit 5a09d8b

Please sign in to comment.