From de5055c98151e9e45522e73eae9dda7616918595 Mon Sep 17 00:00:00 2001 From: hku Date: Wed, 14 Feb 2024 02:10:01 +0800 Subject: [PATCH] copy group to clipboard only when all nodes in the group are selected --- web/lib/litegraph.core.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/web/lib/litegraph.core.js b/web/lib/litegraph.core.js index cf97e6b62..911e61b21 100644 --- a/web/lib/litegraph.core.js +++ b/web/lib/litegraph.core.js @@ -7166,13 +7166,6 @@ LGraphNode.prototype.executeAction = function(action) } clipboard_info.nodes.push(cloned.serialize()); - for (var group of this.graph._groups) { - group.recomputeInsideNodes(); - if (group._nodes?.includes(node) && (!_selected_groups.includes(group))) { - _selected_groups.push(group); - clipboard_info.groups.push(group.serialize()); - } - } if (node.inputs && node.inputs.length) { for (var j = 0; j < node.inputs.length; ++j) { @@ -7200,6 +7193,17 @@ LGraphNode.prototype.executeAction = function(action) } } } + + //if every node in the group are selected, then the group is "selected" + for (var group of this.graph._groups) { + group.recomputeInsideNodes(); + if (group._nodes?.every(function(node){ + return selected_nodes_array.includes(node) + })) { + clipboard_info.groups.push(group.serialize()); + } + } + localStorage.setItem( "litegrapheditor_clipboard", JSON.stringify(clipboard_info)