Skip to content

Commit 7c31c57

Browse files
authored
feat(core): enhance elevate-edges-on-select to support direct edge selection
1 parent 447b2b0 commit 7c31c57

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/core/src/utils/edge.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,14 @@ export function getEdgeZIndex(edge: GraphEdge, findNode: Actions['findNode'], el
103103
}
104104

105105
if (elevateEdgesOnSelect) {
106-
z = hasZIndex ? edge.zIndex! : Math.max(source.computedPosition.z || 0, target.computedPosition.z || 0)
106+
const baseZ = hasZIndex ? edge.zIndex! : 0
107+
const nodeBasedZ = Math.max(source.computedPosition.z || 0, target.computedPosition.z || 0)
108+
const edgeSelectedZ = edge.selected ? 1000 : 0
109+
110+
// Take the maximum elevation to avoid double-stacking when both node and edge are selected
111+
const elevationZ = Math.max(nodeBasedZ - baseZ, edgeSelectedZ)
112+
113+
z = baseZ + elevationZ
107114
}
108115

109116
return z

0 commit comments

Comments
 (0)