Skip to content

Update Node Internals

Edges attach where the canvas last measured a node's handles. When a handle moves without the node changing size - switched to another side, or shifted by CSS - call UpdateNodeInternals so the canvas reads the node again and its edges follow, as React Flow's useUpdateNodeInternals does.

Dynamic
Target
bit Blow

Try it

  • Flip handle side moves the node's source handles between its right and bottom sides; the edge leaves from the new place straight away.
  • Add handle adds another source handle (up to five), spread evenly along the side. Drag from a new handle to Target to connect it.
  • Tick shift handles with CSS on the node: the handles slide along the side, but the edge still ends where they were. Press Update node internals and it jumps to them. Untick it and the edge is left behind again.
  • With the box ticked, drag the node instead: letting go measures it too, and the edge catches up.

How it works

  • The handles are BlowHandles in the node's NodeTemplate; their Position (side), count and Style (where along the side) come from fields of the page.
  • The canvas does not ask the browser where a handle is each time it draws an edge: it measures the nodes - their size and every handle's offset - and edges attach at what was measured. It measures by itself when a node changes size, when handles are added or removed, when a drag or a resize ends, and after each render of the page that hosts it.
  • UpdateNodeInternals("dyn") has the browser layer read the named node again and send it across whatever it last reported; with no ids it reads every node, as Refresh(remeasure: true) does.
  • Flip and Add handle change the page's state, so the page renders and the canvas measures after that render anyway; they call UpdateNodeInternals("dyn") all the same, which is the safe habit whenever code changes a node's handles.
  • The call is indispensable when a handle moves and nothing renders: the CSS box shifts the handles with a :has() rule on the node, which the browser applies without Blazor - or the canvas - hearing of it. A node component re-rendering its own state, or a script, is the same case.
An unhandled error has occurred. Reload 🗙