Skip to content

Commit

Permalink
fix: #5064 Handle case when line has only one point
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Nov 24, 2023
1 parent f604017 commit 78e118c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cypress/integration/rendering/flowchart-v2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,18 @@ A ~~~ B
{}
);
});

it('5064: Should render when subgraph child has links to outside node and subgraph', () => {
imgSnapshotTest(
`flowchart TB
Out --> In
subgraph Sub
In
end
Sub --> In`
);
});

describe('Markdown strings flowchart (#4220)', () => {
describe('html labels', () => {
it('With styling and classes', () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/mermaid/src/utils/lineWithOffset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ function calculateDeltaAndAngle(
): { angle: number; deltaX: number; deltaY: number } {
point1 = pointTransformer(point1);
point2 = pointTransformer(point2);
if (point1 === undefined || point2 === undefined) {
return { angle: 0, deltaX: 0, deltaY: 0 };

Check warning on line 28 in packages/mermaid/src/utils/lineWithOffset.ts

View check run for this annotation

Codecov / codecov/patch

packages/mermaid/src/utils/lineWithOffset.ts#L28

Added line #L28 was not covered by tests
}
const [x1, y1] = [point1.x, point1.y];
const [x2, y2] = [point2.x, point2.y];
const deltaX = x2 - x1;
Expand Down

0 comments on commit 78e118c

Please sign in to comment.