rsilvestre commented on issue #61384:
URL: https://github.com/apache/airflow/issues/61384#issuecomment-3846054209

   Hi @bbovenzi @pierrejeambrun @ryanahamilton 👋
   
   I've identified the root cause of issue #61384 and created a fix. The 
problem occurs when `elk.portConstraints: "FIXED_SIDE"` (added in 3.1.6) is 
applied unconditionally - it breaks graph layout for TB/RL/BT orientations when 
TaskGroups are present.
   
   **Root Cause:**
   The `elk.portConstraints: "FIXED_SIDE"` constraint works correctly for LR 
(RIGHT) orientation but breaks ELK.js layout algorithm for other orientations 
(UP/DOWN/LEFT) when TaskGroups are involved, causing nodes to spread 
horizontally instead of aligning properly.
   
   **Solution:**
   Conditionally apply `elk.portConstraints` only when `direction === "RIGHT"`, 
restoring 3.0.6 behavior for other orientations while preserving the improved 
edge routing for LR.
   
   **Patch:** 
https://gist.github.com/rsilvestre/e37315e3677253eec075f3d5af31f460
   
   The fix modifies 
`airflow-core/src/airflow/ui/src/components/Graph/useGraphLayout.ts` in two 
places:
   1. Open TaskGroup `layoutOptions` (line ~180): Only apply portConstraints 
when `direction === "RIGHT"`
   2. Individual node `layoutOptions` (line ~240): Only apply portConstraints 
when `direction === "RIGHT"`
   
   **Testing:**
   ✅ Tested on Airflow 3.1.6 with TaskGroups
   ✅ All orientations (TB/BT/RL/LR) now render correctly
   ✅ Matches 3.0.6 behavior for non-LR orientations
   ✅ No regression for LR orientation


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to