fix: stabilize sibling edge offset ordering in adjustVertices#116
fix: stabilize sibling edge offset ordering in adjustVertices#116willeastcott merged 1 commit intomainfrom
Conversation
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
There was a problem hiding this comment.
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
siblingsarray by model ID before perpendicular offset assignment inadjustVertices, 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.
Summary
adjustVerticesbefore assigning perpendicular offsets, ensuring stable positioning across calls regardless of internal JointJS cell reordering fromtoBack()/toFront()operationsTest plan