Skip to content

fix: stabilize sibling edge offset ordering in adjustVertices#116

Merged
willeastcott merged 1 commit intomainfrom
fix/edge-position-swap
Mar 8, 2026
Merged

fix: stabilize sibling edge offset ordering in adjustVertices#116
willeastcott merged 1 commit intomainfrom
fix/edge-position-swap

Conversation

@willeastcott
Copy link
Copy Markdown
Contributor

@willeastcott willeastcott commented Mar 8, 2026

Summary

  • Fixes transition arrows visually swapping position on first click (Transition arrows visually switch position #107)
  • Sorts sibling edges by model ID in adjustVertices before assigning perpendicular offsets, ensuring stable positioning across calls regardless of internal JointJS cell reordering from toBack()/toFront() operations

Test plan

Sort siblings by model ID before assigning perpendicular offsets so
that the visual position of edges between the same pair of nodes is
deterministic across calls. The internal JointJS cell order can change
due to toBack/toFront operations, which previously caused edges to
swap position on first click.

Fixed #107

Made-with: Cursor
@willeastcott willeastcott requested a review from Copilot March 8, 2026 09:11
@willeastcott willeastcott self-assigned this Mar 8, 2026
@willeastcott willeastcott added the bug Something isn't working label Mar 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a visual bug (#107) where transition arrows between two nodes would swap their perpendicular positions on the first user click. The root cause was that graph.getLinks() returns links in the order they appear in the internal cell array, and that order changes whenever any link calls link.toBack() (which every edge does in GraphViewEdge upon mounting to the DOM). Because adjustVertices assigned perpendicular offsets based on array index, the first cell:pointerup event after page load would process links in a different order than the initial layout pass, causing the offsets to flip.

Changes:

  • Added a stable sort of the siblings array by model ID before perpendicular offset assignment in adjustVertices, making the offset-to-link mapping deterministic regardless of internal cell reordering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@willeastcott willeastcott merged commit 550c503 into main Mar 8, 2026
6 checks passed
@willeastcott willeastcott deleted the fix/edge-position-swap branch March 8, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants