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