mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
fix: handle undefined edge list in insertEdge to prevent runtime error
Fixes a runtime error in cose-bilkent layout caused by insertEdge calling .filter() on an undefined edge list. Now defaults to an empty array to prevent the crash. on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -115,6 +115,18 @@ export const render = async (
|
||||
}
|
||||
});
|
||||
|
||||
layoutResult.edges.forEach((positionedEdge) => {
|
||||
const edge = data4Layout.edges.find((e) => e.id === positionedEdge.id);
|
||||
if (edge) {
|
||||
// Update the edge data with positioned coordinates
|
||||
edge.points = [
|
||||
{ x: positionedEdge.startX, y: positionedEdge.startY },
|
||||
{ x: positionedEdge.midX, y: positionedEdge.midY },
|
||||
{ x: positionedEdge.endX, y: positionedEdge.endY },
|
||||
];
|
||||
}
|
||||
});
|
||||
|
||||
// Step 4: Insert and position edges
|
||||
log.debug('Inserting and positioning edges');
|
||||
|
||||
@@ -134,10 +146,7 @@ export const render = async (
|
||||
if (positionedEdge) {
|
||||
log.debug('APA01 positionedEdge', positionedEdge);
|
||||
// Create edge path with positioned coordinates
|
||||
const edgeWithPath = {
|
||||
...edge,
|
||||
points: positionedEdge.points,
|
||||
};
|
||||
const edgeWithPath = { ...edge };
|
||||
|
||||
// Insert the edge path
|
||||
const paths = insertEdge(
|
||||
|
@@ -128,6 +128,7 @@ export interface Edge {
|
||||
thickness?: 'normal' | 'thick' | 'invisible' | 'dotted';
|
||||
look?: string;
|
||||
isUserDefinedId?: boolean;
|
||||
points?: Point[];
|
||||
}
|
||||
|
||||
export interface RectOptions {
|
||||
|
Reference in New Issue
Block a user