fix(ConnectorShape): ignore unset arrows in edge bounding box - #1094
Conversation
…ingBox Default an absent startArrow/endArrow to NONE before comparing, so an unset arrow no longer enlarges the bounding box. The strict `this.style.startArrow !== NONE` check evaluated `undefined !== 'none'` as true, running the branch for arrows that were never set and growing the box by an extra marker size per side. This shrank the computed graph bounds and the fit scale slightly compared to mxGraph. mxGraph mxConnector.augmentBoundingBox reads arrows via getValue(style, ARROW, NONE), which defaults absent keys to NONE. The fix mirrors that with `(this.style.startArrow ?? NONE) !== NONE`, also aligning with createMarker in the same file which already defaults the arrow type to NONE. Add data-driven tests on augmentBoundingBox covering: only end arrow set, only start arrow set, no arrow set, explicit none on both sides, and both arrows set.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Walkthrough
ChangesConnectorShape undefined-arrow fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|



PR Checklist
maxGraph, and you are assigned to the issue.Overview
ConnectorShape.augmentBoundingBoxtreated an unsetstartArrow/endArrowas present, so an edge with no arrow on a side still grew its bounding box by an extra marker size on that side.The check was a strict comparison against
NONE:When the style does not define the arrow,
this.style.startArrowisundefined, andundefined !== 'none'istrue, so the branch runs for arrows that were never set. This grows the bounding box (and therefore the graph bounds and the computed fit scale) more than it should.This is a porting regression from mxGraph.
mxConnector.augmentBoundingBoxreads the arrow withgetValue(style, ARROW, NONE), which defaults an absent key toNONE, so the branch is correctly skipped.The fix defaults the value before comparing, mirroring mxGraph and aligning with
createMarkerin the same file which already uses... || NONE:Tests: data-driven coverage was added on
augmentBoundingBoxfor the cases only end arrow set, only start arrow set, no arrow set, explicitnoneon both sides, and both arrows set. The first three were red before the fix.Notes
While investigating this, it became clear that the mxGraph to maxGraph migration introduced regressions in several places where a style default value is not handled the way mxGraph handled it (mxGraph systematically went through
getValue(style, KEY, default), whereas maxGraph sometimes reads the property directly and compares it without applying the default). Several such cases have already been fixed individually, but we will need to conduct a general investigation to systematically compare the default values used in mxGraph and maxGraph, to catch the remaining occurrences rather than fixing them one by one as they are discovered.Summary by CodeRabbit
Bug Fixes
Tests