fix(routers.rightAngle): allow zero-value margins and un-clamp minPathMargin - #3435
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts the rightAngle router option handling in @joint/core so zero-valued margins are honored and minPathMargin can widen (not just narrow) the overlap-detection zone. It also updates router tests accordingly and rewrites the right-angle-playground-js example into an interactive, visual demo for tuning these margins.
Changes:
- Use nullish coalescing (
??) formargin,sourceMargin, andtargetMargin, and stop clampingminPathMarginto per-side margins. - Update/add QUnit coverage for
margin: 0,sourceMargin: 0,targetMargin: 0, andminPathMargin > margin, plus rename priorminMargintest usage tominPathMargin. - Rework the
right-angle-playground-jsexample into a slider-driven demo that visualizes margin bands.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/joint-core/src/routers/rightAngle.mjs | Updates router option defaults so 0 is respected and minPathMargin is no longer clamped. |
| packages/joint-core/test/jointjs/routers.js | Adjusts/extends tests to cover zero-margins and widened minPathMargin, and aligns naming with the public option. |
| examples/right-angle-playground-js/index.html | Adds a toolbar UI for live-tuning margin-related router options. |
| examples/right-angle-playground-js/src/main.js | Implements interactive router option binding and margin visualization on elements/link. |
| examples/right-angle-playground-js/src/styles.css | Adds toolbar/control styling and updates the demo’s look/feel. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kumilingus
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rightAnglerouter used||formargin,sourceMargin, andtargetMargin, so0was silently coerced back to the default (20/margin) instead of being honored.minPathMarginwas clamped withMath.min(opt.minPathMargin, sourceMargin/targetMargin), so it could only ever narrow the overlap-detection zone, never widen it beyondmargin.??, so0is respected andminPathMargincan be set larger thanmarginto intentionally widen the detour-detection zone.right-angle-playground-jsexample into an interactive demo with live sliders forsourceMargin,targetMargin, andminPathMargin, visualizing each margin as a band around the elements/link.Test plan
margin: 0,sourceMargin: 0, andtargetMargin: 0.minPathMarginlarger thanmarginactually changes the route.minMargintest option tominPathMarginand adjusted element positions so the "with"/"without" assertions in each of those tests actually diverge instead of asserting identical paths.grunt karma:jointpasses fortest/jointjs/routers.js(66/66); fulljointsuite shows only 2 pre-existing, unrelated failures (util.breakText ellipsis,port labels label attributes).eslintclean on the modified test file.🤖 Generated with Claude Code