Skip to content

Provider

A sidebar outside the canvas reads the graph and drives the flow - what wrapping a flow in ReactFlowProvider is for in React. Blazor needs no provider: the node and edge lists are already shared state, and a reference to the canvas can be handed to whatever needs to call it.

Node 1
bit Blow

Try it

  • Add node adds the next node to the grid, and the view glides out to keep every node in sight.
  • Connect last two joins the two newest nodes; pressing it again adds nothing, since they are already joined.
  • Fit view fits the whole graph into the pane.
  • Press a node's name in the list: the view moves to that node, selects it and gives it keyboard focus, so the arrow keys move it straight away.
  • Work on the canvas - click to select, drag from a handle to connect, press Delete - and the counts and the list follow: the sidebar marks the selected nodes.

How it works

  • The sidebar is ordinary markup beside the BlowCanvas, not inside it. Its counts and its list read the same List<BlowNode> and List<BlowEdge> the canvas was given and edits in place.
  • OnInit hands over the canvas reference once it has rendered and measured; the sidebar's buttons are disabled until then. @ref does the same job. To reach the canvas from another component, pass the reference down as a parameter or a cascading value - the part React's provider plays.
  • NodesChanged, EdgesChanged and OnSelectionChange re-render the page after each completed edit and each change of selection - once when a drag is released, not on every pointer move - so the sidebar stays in step.
  • Add node and Connect last two call AddNodes and AddEdges, then FitViewAsync(300) eases the view over 300 ms to fit what is there now.
  • A name in the list calls FocusNodeAsync(id, select: true, durationMs: 300): it centres the view on the node, makes it the selection and moves keyboard focus to it.
An unhandled error has occurred. Reload 🗙