fix(zIndex): allow zIndex to be set to 0 explicitly

This commit is contained in:
Christopher Möller
2021-11-24 12:23:03 +01:00
parent 0f480444f2
commit cffefe78c8
+4 -1
View File
@@ -3,12 +3,15 @@ import { useCallback } from 'react';
import { useStore } from '../store';
import { isEdgeVisible } from '../container/EdgeRenderer/utils';
import { ReactFlowState, NodeInternals, Edge } from '../types';
import { isNumeric } from '../utils';
function groupEdgesByZLevel(edges: Edge[], nodeInternals: NodeInternals) {
let maxLevel = -1;
const levelLookup = edges.reduce<Record<string, Edge[]>>((tree, edge) => {
const z = edge.zIndex || Math.max(nodeInternals.get(edge.source)?.z || 0, nodeInternals.get(edge.target)?.z || 0);
const z = isNumeric(edge.zIndex)
? edge.zIndex
: Math.max(nodeInternals.get(edge.source)?.z || 0, nodeInternals.get(edge.target)?.z || 0);
if (tree[z]) {
tree[z].push(edge);
} else {