Skip to content

[DS 2.0] Use the measured source-node height for self-loop edges - #121

Draft
librowski wants to merge 1 commit into
design-system-2.0from
ds2-canvas-edges
Draft

[DS 2.0] Use the measured source-node height for self-loop edges#121
librowski wants to merge 1 commit into
design-system-2.0from
ds2-canvas-edges

Conversation

@librowski

@librowski librowski commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Problem

LabelEdge computed a source-node height to place the label of a self-connecting edge but did not pass it to SelfConnectingEdge, whose nodeHeight prop defaulted to 0: the loop was drawn as if the node had no height while the label was positioned as if it had. The height itself was read from sourceNode.height, which xyflow 12 sets only when a change explicitly requests attributes - normal ResizeObserver updates write measured.height.

A first version read the height through getNode(); a browser check (review of 8.09) showed that a snapshot read does not follow a later remeasurement: after adding a branch to a Decision node the loop and label stayed at the old height until an unrelated rerender.

Change

  • LabelEdge subscribes to the source node's height in the React Flow store (useStore, aliased to keep it distinct from the SDK store): measured.height ?? height ?? 0, 0 for non-self edges. The value drives both the loop path (SelfConnectingEdge.nodeHeight) and the label Y.
  • Spec covers the measured-height path, the fallback to an explicit height, and an unknown node (zero) through the store selector.
  • Changeset: @workflowbuilder/sdk patch (LabelEdge and SelfConnectingEdge are public exports).

Not covered by an automated test: the live remeasurement itself (the spec exercises the selector with a mocked store; a real React Flow harness would be a new test layer).

Out of scope, to settle with design

Edge corner radius has three values today: 16px in code (EDGE_CURVE_RADIUS), 2px in the token export (canvas-edge-corner-radius), 18px in the Figma vectors. Adopting the export would visibly straighten every corner; not changed here.

…and label

LabelEdge subscribes to the source node's height in the React Flow store
(measured.height, then height, then 0) instead of reading a getNode()
snapshot, so the loop path and its label follow every remeasurement -
xyflow 12 writes ResizeObserver results to measured.height only. The same
value is passed to SelfConnectingEdge, whose nodeHeight prop previously
defaulted to 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant