From 85edee288f2a06a59b0598108e0e46b1db906cbe Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 5 Aug 2020 11:16:53 +0100 Subject: [PATCH] Allow lasso selection to be restricted to active group --- .../@node-red/editor-client/src/js/ui/view.js | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js index faa7ea810..d488ed201 100755 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js @@ -1558,17 +1558,28 @@ RED.view = (function() { var y = parseInt(lasso.attr("y")); var x2 = x+parseInt(lasso.attr("width")); var y2 = y+parseInt(lasso.attr("height")); + var ag = activeGroup; if (!d3.event.shiftKey) { clearSelection(); + if (ag) { + if (x < ag.x+ag.w && x2 > ag.x && y < ag.y+ag.h && y2 > ag.y) { + // There was an active group and the lasso intersects with it, + // so reenter the group + enterActiveGroup(ag); + activeGroup.selected = true; + } + } } activeGroups.forEach(function(g) { if (!g.selected) { if (g.x > x && g.x+g.w < x2 && g.y > y && g.y+g.h < y2) { - while (g.g) { - g = RED.nodes.group(g.g); - } - if (!g.selected) { - selectGroup(g,true); + if (!activeGroup || RED.group.contains(activeGroup,g)) { + while (g.g && (!activeGroup || g.g !== activeGroup.id)) { + g = RED.nodes.group(g.g); + } + if (!g.selected) { + selectGroup(g,true); + } } } } @@ -1577,18 +1588,21 @@ RED.view = (function() { activeNodes.forEach(function(n) { if (!n.selected) { if (n.x > x && n.x < x2 && n.y > y && n.y < y2) { - if (n.g) { - var group = RED.nodes.group(n.g); - while (group.g) { - group = RED.nodes.group(group.g); + if (!activeGroup || RED.group.contains(activeGroup,n)) { + if (n.g && (!activeGroup || n.g !== activeGroup.id)) { + console.log("HERE") + var group = RED.nodes.group(n.g); + while (group.g && (!activeGroup || group.g !== activeGroup.id)) { + group = RED.nodes.group(group.g); + } + if (!group.selected) { + selectGroup(group,true); + } + } else { + n.selected = true; + n.dirty = true; + movingSet.add(n); } - if (!group.selected) { - selectGroup(group,true); - } - } else { - n.selected = true; - n.dirty = true; - movingSet.add(n); } } }