fix(zIndex): allow zIndex to be set to 0 explicitly
This commit is contained in:
@@ -3,12 +3,15 @@ import { useCallback } from 'react';
|
|||||||
import { useStore } from '../store';
|
import { useStore } from '../store';
|
||||||
import { isEdgeVisible } from '../container/EdgeRenderer/utils';
|
import { isEdgeVisible } from '../container/EdgeRenderer/utils';
|
||||||
import { ReactFlowState, NodeInternals, Edge } from '../types';
|
import { ReactFlowState, NodeInternals, Edge } from '../types';
|
||||||
|
import { isNumeric } from '../utils';
|
||||||
|
|
||||||
function groupEdgesByZLevel(edges: Edge[], nodeInternals: NodeInternals) {
|
function groupEdgesByZLevel(edges: Edge[], nodeInternals: NodeInternals) {
|
||||||
let maxLevel = -1;
|
let maxLevel = -1;
|
||||||
|
|
||||||
const levelLookup = edges.reduce<Record<string, Edge[]>>((tree, edge) => {
|
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]) {
|
if (tree[z]) {
|
||||||
tree[z].push(edge);
|
tree[z].push(edge);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user