Reuse first group name/style when merging elements

Fixes #2680
This commit is contained in:
Nick O'Leary 2020-09-03 13:28:35 +01:00
parent d9900d8e4c
commit 716dc781e4
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 9 additions and 0 deletions

View File

@ -380,11 +380,16 @@ RED.group = (function() {
return;
}
}
var existingGroup;
// Second pass, ungroup any groups in the selection and add their contents
// to the selection
for (var i=0; i<selection.nodes.length; i++) {
n = selection.nodes[i];
if (n.type === "group") {
if (!existingGroup) {
existingGroup = n;
}
ungroupHistoryEvent.groups.push(n);
nodes = nodes.concat(ungroup(n));
} else {
@ -398,6 +403,10 @@ RED.group = (function() {
// Finally, create the new group
var group = createGroup(nodes);
if (group) {
if (existingGroup) {
group.style = existingGroup.style;
group.name = existingGroup.name;
}
RED.view.select({nodes:[group]})
}
historyEvent.events.push({