Skip to content

Conversation

@lmac-1
Copy link
Collaborator

@lmac-1 lmac-1 commented Jan 23, 2026

Description

This PR fixes a bug where converging edges would swap positions when selected on the diagram.

The issue was caused by sortOrderForSvg reordering edges based on selection state, which affected Dagre's layout decisions. The fix preserves stable edge order regardless of selection.

Before:
image

After:
image

See the bug in action: https://www.loom.com/share/302055f6f3b748f1a4523ef7ccef67af

Closes #4328

Validation steps

  1. Open workflow with multiple branching points
  2. Make sure your diagram is on auto layout mode
  3. Click edges from different parent nodes
  4. Click edges that lead to converging paths
  5. Expected: All paths maintain their positions

Additional notes for the reviewer

  1. If you have bigger workflows - perhaps click around on the paths and make sure that everything behaves as expected
  2. I suspected that this sorting algorithm was to ensure that the edges stayed on top in terms of z-index. I've verified both with and without the fix that the behaviour remains the same when there are edges that are on top of each other.

AI Usage

Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):

  • I have used Claude Code
  • I have used another model
  • I have not used AI

You can read more details in our
Responsible AI Policy

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review
    with Claude Code)
  • I have implemented and tested all related authorization policies.
    (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

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.
@github-project-automation github-project-automation bot moved this to New Issues in v2 Jan 23, 2026
@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.32%. Comparing base (549de66) to head (9a6a604).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4348      +/-   ##
==========================================
+ Coverage   89.29%   89.32%   +0.02%     
==========================================
  Files         425      425              
  Lines       19994    19994              
==========================================
+ Hits        17854    17859       +5     
+ Misses       2140     2135       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New Issues

Development

Successfully merging this pull request may close these issues.

Shifty Path and Step Behavior on Auto-Layout Mode

2 participants