Skip to content

Commit ca77d0e

Browse files
committed
fix(edges): draw connection line when there are no edges closes xyflow#1785
1 parent 248de60 commit ca77d0e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/hooks/useVisibleEdges.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { isEdgeVisible } from '../container/EdgeRenderer/utils';
55
import { ReactFlowState, NodeInternals, Edge } from '../types';
66
import { isNumeric } from '../utils';
77

8+
const defaultEdgeTree = [{ level: 0, isMaxLevel: true, edges: [] }];
9+
810
function groupEdgesByZLevel(edges: Edge[], nodeInternals: NodeInternals) {
911
let maxLevel = -1;
1012

@@ -23,7 +25,7 @@ function groupEdgesByZLevel(edges: Edge[], nodeInternals: NodeInternals) {
2325
return tree;
2426
}, {});
2527

26-
return Object.entries(levelLookup).map(([key, edges]) => {
28+
const edgeTree = Object.entries(levelLookup).map(([key, edges]) => {
2729
const level = +key;
2830

2931
return {
@@ -32,6 +34,12 @@ function groupEdgesByZLevel(edges: Edge[], nodeInternals: NodeInternals) {
3234
isMaxLevel: level === maxLevel,
3335
};
3436
});
37+
38+
if (edgeTree.length === 0) {
39+
return defaultEdgeTree;
40+
}
41+
42+
return edgeTree;
3543
}
3644

3745
function useVisibleEdges(onlyRenderVisible: boolean, nodeInternals: NodeInternals) {

0 commit comments

Comments
 (0)