-
Notifications
You must be signed in to change notification settings - Fork 61
Fix converging edges swapping positions when selected #4348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Fixes #4328 When clicking different edges in auto-layout mode, paths would swap positions because sortOrderForSvg was reordering edges based on selection state. Dagre's layout algorithm uses edge order to determine positioning when disableOptimalOrderHeuristic is enabled. Fix by removing selection-based sorting and preserving stable edge order. Only disabled/enabled status affects sort order now.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4348 +/- ##
==========================================
+ Coverage 89.29% 89.33% +0.04%
==========================================
Files 425 425
Lines 19994 19994
==========================================
+ Hits 17854 17862 +8
+ Misses 2140 2132 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
doc-han
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works perfectly 🎉
Can we remove the comments with the PR number in them?
Also, I'm yet to understand why the sort function was initially made to work in that manner(pushing the selected edge to the bottom).
| return -1; | ||
| } | ||
|
|
||
| return a.selected - b.selected; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix.
I'm trying to understand why this code existed in the first place. Seems to have zero value and I can't understand why it was like this.
doc-han
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the comments with PR numbers? Thanks.
|
@doc-han thanks for the review. I've fixed the comments referring to the PR. Can you check it again? Also re the sorting function, I asked my good friend Claude and it seems to think that it "ensures disabled edges render behind enabled edges in the SVG." So I think it's best if we keep it in! |
Description
This PR fixes a bug where converging edges would swap positions when selected on the diagram.
The issue was caused by
sortOrderForSvgreordering edges based on selection state, which affected Dagre's layout decisions. The fix preserves stable edge order regardless of selection.Before:

After:

See the bug in action: https://www.loom.com/share/302055f6f3b748f1a4523ef7ccef67af
Closes #4328
Validation steps
Additional notes for the reviewer
AI Usage
Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):
You can read more details in our
Responsible AI Policy
Pre-submission checklist
/reviewwith Claude Code)
(e.g.,
:owner,:admin,:editor,:viewer)