Skip to content

Keep connection paths correct on every frame of a drag - #329

Merged
dovvnloading merged 1 commit into
mainfrom
fix/edge-path-per-frame
Aug 14, 2026
Merged

Keep connection paths correct on every frame of a drag#329
dovvnloading merged 1 commit into
mainfrom
fix/edge-path-per-frame

Conversation

@dovvnloading

Copy link
Copy Markdown
Owner

Problem

Screenshots of the live symptom show the connection drawn at the position the node occupied earlier in the gesture - a gap of hundreds of pixels during a fast drag, closing as soon as movement stops. That distance is far more than one frame of movement, so this is not simply a late repaint: something is actively drawing the connection from records that trail the gesture.

Writing the path once per pointer event, as #328 did, is not sufficient on its own. React Flow re-renders those same edges from its own node records immediately afterwards, and if those records are behind the gesture, that render overwrites the correct path with a stale one. The result on screen is unchanged - which matches the report that #328 made no observable difference.

Change

The correct geometry is now the last write before every paint for the duration of the gesture, rather than only at the moment each pointer event is handled. An animation-frame loop, alive only while a drag is in progress, redraws the affected connections from the latest corrected positions. Whatever React renders in between can no longer be what ends up on screen.

The loop is torn down when the gesture ends, and also if the canvas unmounts mid-gesture.

Test plan

  • Full frontend check passes: schema, types, lint (0 errors), 1931/1931 tests, production build, bundle size
  • On the affected machine: drag a connected node slowly and quickly, and confirm the line stays attached to the connection dot throughout

Screenshots of the live symptom show the line drawn at the position the
node occupied earlier in the gesture, with a gap of hundreds of pixels on
a fast drag, closing as soon as movement stops. The distance is far more
than one frame's worth of movement, so the geometry is not merely late:
something is actively drawing the connection from records that trail the
gesture.

Writing the path once per pointer event, as the previous change did, is
not enough on its own. React Flow re-renders the same edges from its own
node records immediately afterwards, and if those records are behind the
gesture, that render overwrites the correct path with a stale one. The
net result on screen is unchanged, which matches the report that the
previous change made no difference.

The correct geometry is now the last write before every paint for the
whole gesture, not just at the moment each pointer event is handled. An
animation-frame loop, alive only while a drag is in progress, redraws the
affected connections from the latest corrected positions. Whatever React
renders in between can no longer be what the user sees. The loop is torn
down when the gesture ends and if the canvas unmounts mid-gesture.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@dovvnloading
dovvnloading merged commit f11152c into main Aug 14, 2026
@dovvnloading
dovvnloading deleted the fix/edge-path-per-frame branch August 15, 2026 14:41
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