question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stability of nodes and edges levels

See original GitHub issue

Describe the Bug

A node can be displayed at the max z-index level when selected, but when it is deselected, its level will be reset to the initial level (which is defined by the render order I think). Therefore, a user cannot rearrange the level order of the nodes. This behavior is a little unconventional and may cause some problems in applications.

Your Example Website or App

https://reactflow.dev/docs/examples/overview/

Steps to Reproduce the Bug or Issue

  1. Drag one of the upper nodes over some of the lower nodes. The upper node will cover the lower ones.
  2. Click the blanket to deselect the upper node.
  3. The upper node is covered by the lower ones.

Expected behavior

The levels of the nodes shouldn’t be affected by deselection.

Screenshots or Videos

https://user-images.githubusercontent.com/10386119/158810010-91d4d5d4-1406-45ac-9728-8ee819b2d7c4.mp4

Platform

  • OS: [Windows]
  • Browser: [Edge]
  • Version: [v10]

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
chrtzecommented, Mar 21, 2022

Thanks for your thoughts on the updated zIndex logic. We have designed the default behavior of the nodes and edges in React Flow v10 like this:

  • nodes are being rendered above the edges according to their order in the nodes array
  • edges are being rendered behind the nodes according to their order in the edges array
  • edges inherit the zIndex of their source or target with the highest zIndex (default will be 0)
  • once a node is selected or dragged, it gets zIndex 1000 (we should probably make this value configurable in the future) to lift the node and their connected edges above everything else

This behavior can be customized:

  • to control the initial stacking order, simply change the order of the nodes and edges in their arrays
  • to disable the elevation of nodes on select/drag, you can apply a zIndex option to the nodes, this value will take precedence over the default value (1000)
  • to disable the elevation of edges on node select/drag, you can apply a zIndex option to the edges or set defaultEdgeOptions={{ zIndex: 0 }}

I agree that this seems to be too complicated, if you want to have the v9 behavior out of the box. Maybe we can add a property that allows to control this behavior, but for now I think the easiest way is to use defaultEdgeOptions={{ zIndex: 0 }}.

1reaction
AustinGilliamcommented, Mar 17, 2022

@AustinGilliam Hi, do you mean that you do not want the edges to be risen up by selecting the nodes? I personally like this behavior. And I believe this is introduced because of the sub flows feature. The levels of edges are determined by their connected nodes, so if the problem stated in this issue is resolved, I believe all the edges will be good too. Actually there’s a another problem caused by the introduction of z-index into edges, for which I opened an issue here: #1966

I personally don’t like it if you’re using edge labels, because you can drag a node such that the label of its edge completely occludes another node label beneath it. Github seems to be having some issues, as I can’t currently upload a screenshot. You can replicate in the Overview Example by dragging “This is a default node” such that the edge label occludes “Node id: 5”.

edge-label-over-node-label

This also causes issues with custom nodes that have “badges” attached to them, e.g. some architecture styles have visual elements that extend beyond the border of the base node (see below). In this case, the edge will show above the badges on the left, which isn’t functionally breaking anything, but is not visually pleasing.

image

However, I get the rationale from a grouping perspective, so it’s tricky. I would expect that if I had Group Node A with children Nodes B and C, and an Edge E between B-C, that the z-index of E would be higher than A. Maybe it could be a togglable option? I understand that the use case I described above is a probably a little niche, so I’d be happy to manually set the z-index in my case.

Edit: Added pictures now that Github Issues is stable again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A framework for stability‐based module detection in ... - NCBI
Our approach to estimating module stability has several objectives: to identify a threshold for defining a correlation graph that gives rise to stable...
Read more >
Stability of Dynamical Systems on a Graph
We investigate two notions of stability; the first is connective stability, where the overall system is stable in the sense of Lyapunov despite...
Read more >
Stability notions in synthetic graph generation
Figure 1: Node-level changes between instances. In graph instances G1 and G2, node Angela is a “leader” with rel- atively high in-degree. In...
Read more >
Stability of graph communities across time scales
The optimality of this partition follows from the fact that clustering vertices i and j together induce a variation in [5] given by...
Read more >
Stability of network centrality measures: a numerical study
The first perturbation method relies on the changing edge weights on fixed node and edge sets of graphs representing real-life processes. S&P ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found