Skip to content

Update Node

Change a node from outside the canvas - its label, colour, position and interaction flags - by setting properties on the BlowNode and letting the page re-render, as React Flow's updateNode example does. Duplicate copies the node, with everything set on it, through BlowNode.Clone.

Node
Output
bit Blow

Try it

  • Type a label: node 1 is relabelled as you type, and grows or shrinks to fit.
  • Pick a bg colour: node 1's background changes.
  • Press Move randomly: node 1 jumps somewhere else and the view follows it.
  • Press Duplicate: a copy of node 1 appears beside it, with its label, colour and flags as they are now. Copies are independent: the toolbar goes on changing node 1 only.
  • Untick draggable: node 1 no longer moves, by pointer or arrow keys, and loses the grab cursor - but can still be selected and connected.
  • Untick selectable: clicks, Shift+drag boxes and Ctrl+A pass node 1 by - but it can still be dragged.
  • Untick connectable: no connection can start from or end on node 1's handles.
  • Untick focusable, click the background and press Tab: focus moves through the edges and the other nodes but skips node 1.

How it works

  • BlowNode is a mutable class: the toolbar sets Label, Style and Position on the node in the list, and the canvas draws the change on the render that follows. A node without an explicit size is measured again when its content changes.
  • FitViewAsync(300) eases the view to the graph after the move, so the node never leaves the screen.
  • Clone(newId) copies every property of the node under a new id - label, style, size, flags; Data is shared by reference rather than copied. The page offsets the copy's Position and clears Selected before adding it to the list.
  • Draggable, Selectable, Connectable and Focusable are all on by default. Each turns one kind of interaction off for this node alone; NodesDraggable, NodesConnectable, ElementsSelectable and NodesFocusable on the canvas do the same for every node.
  • A node that is already selected stays selected when it stops being selectable, so the page clears Selected as it unticks the box.
An unhandled error has occurred. Reload 🗙