diff --git a/docs/src/joint/api/connectionPoints/boundary.html b/docs/src/joint/api/connectionPoints/boundary.html index e472d99ae..9f5373124 100644 --- a/docs/src/joint/api/connectionPoints/boundary.html +++ b/docs/src/joint/api/connectionPoints/boundary.html @@ -39,7 +39,7 @@ selector string - A selector to identify subelement/magnet of the end element at whose boundary we want the connection point to be found. Default is undefined, meaning that the first non-group descendant of the end element's node will be considered. (An example of another setting that may be useful is 'root', which forces the usage of the root group bbox instead.) + A selector to identify subelement/magnet of the end element at whose boundary we want the connection point to be found. Default is undefined, meaning that the first non-group descendant of the end element's node will be considered. (An example of another setting that may be useful is 'root', which forces the usage of the root group bbox instead.). If set to false, the magnet is used as is, even if it is an SVGGroup (it's the most suitable for use in conjunction with magnetSelector). stroke diff --git a/src/connectionPoints/index.mjs b/src/connectionPoints/index.mjs index c5793115c..2b7587052 100644 --- a/src/connectionPoints/index.mjs +++ b/src/connectionPoints/index.mjs @@ -132,6 +132,8 @@ function boundaryIntersection(line, view, magnet, opt) { if (typeof selector === 'string') { node = view.findBySelector(selector)[0]; + } else if (selector === false) { + node = magnet; } else if (Array.isArray(selector)) { node = util.getByPath(magnet, selector); } else { diff --git a/test/jointjs/connectionPoints.js b/test/jointjs/connectionPoints.js index a5d9d8afa..417c95811 100644 --- a/test/jointjs/connectionPoints.js +++ b/test/jointjs/connectionPoints.js @@ -266,6 +266,28 @@ QUnit.module('connectionPoints', function(hooks) { line = new g.Line(tp.clone(), sp.clone()); cp = connectionPointFn.call(lv1, line, rv1, rv1.el, { selector: null }); assert.ok(cp.round().equals(r1.getBBox().rightMiddle())); + + // Disabling the magnet lookup should use the magnet + // passed to the connector even if it is a group node. + r1.set('markup', [{ + tagName: 'g', + selector: 'wrapper', + children: [{ + tagName: 'rect', + selector: 'quarter' + }, { + tagName: 'rect', + selector: 'full', + }] + }]); + // lookup off + line = new g.Line(tp.clone(), sp.clone()); + cp = connectionPointFn.call(lv1, line, rv1, rv1.findBySelector('wrapper')[0], { selector: false }); + assert.ok(cp.round().equals(r1.getBBox().rightMiddle())); + // lookup on + line = new g.Line(tp.clone(), sp.clone()); + cp = connectionPointFn.call(lv1, line, rv1, rv1.findBySelector('wrapper')[0], { selector: undefined }); + assert.ok(cp.round().equals(r1.getBBox().center().offset(25, 0))); }); diff --git a/types/joint.d.ts b/types/joint.d.ts index 7345dcdb3..03d33fadd 100644 --- a/types/joint.d.ts +++ b/types/joint.d.ts @@ -3694,7 +3694,7 @@ export namespace connectionPoints { } interface BoundaryConnectionPointArguments extends StrokeConnectionPointArguments { - selector?: Array | string; + selector?: Array | string | false; precision?: number; extrapolate?: boolean; sticky?: boolean;