Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edge flickering fix #6198

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/mermaid/src/diagrams/flowchart/flowDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ export const addSingleLink = function (_start: string, _end: string, type: any,
}
if (id) {
edge.id = id;
} else {
const existingLinks = edges.filter((e) => e.start === edge.start && e.end === edge.end);
if (existingLinks.length === 0) {
edge.id = `${edge.start}-${edge.end}-${edge.length}`;
} else {
edge.id = `${edge.start}-${edge.end}-${existingLinks.length + 1}`;
}
}

if (edges.length < (config.maxEdges ?? 500)) {
Expand Down Expand Up @@ -267,9 +274,11 @@ export const addLink = function (_start: string[], _end: string[], linkData: unk

log.info('addLink', _start, _end, id);

let idIsUsed = false;
for (const start of _start) {
for (const end of _end) {
addSingleLink(start, end, linkData, id);
addSingleLink(start, end, linkData, !idIsUsed ? id : undefined);
idIsUsed = true;
}
}
};
Expand Down
Loading