Fix adding users to history if multiple props modified

This commit is contained in:
GogoVega 2024-06-26 09:22:01 +02:00
parent 53e092e484
commit ed4b98b598
No known key found for this signature in database
GPG Key ID: E1E048B63AC5AC2B

View File

@ -1534,6 +1534,7 @@ RED.editor = (function() {
if (scope) { if (scope) {
const newUsers = editing_config_node.users.filter(function (node) { const newUsers = editing_config_node.users.filter(function (node) {
let keepNode = false; let keepNode = false;
let nodeModified = null;
for (const d in node._def.defaults) { for (const d in node._def.defaults) {
if (node._def.defaults.hasOwnProperty(d)) { if (node._def.defaults.hasOwnProperty(d)) {
@ -1544,15 +1545,19 @@ RED.editor = (function() {
// this config node in the correct scope. // this config node in the correct scope.
keepNode = true; keepNode = true;
} else { } else {
historyEvents.push({ if (!nodeModified) {
nodeModified = {
t: "edit", t: "edit",
node: node, node: node,
changes: { [d]: node[d] }, changes: { [d]: node[d] },
changed: node.changed, changed: node.changed,
dirty: node.dirty dirty: node.dirty
}); };
} else {
nodeModified.changes[d] = node[d];
}
// Remove the reference to the config // Remove the reference to the config node
node[d] = ""; node[d] = "";
} }
} }
@ -1560,6 +1565,11 @@ RED.editor = (function() {
} }
} }
// Add the node modified to the history
if (nodeModified) {
historyEvents.push(nodeModified);
}
// Mark as changed and revalidate this node // Mark as changed and revalidate this node
if (!keepNode) { if (!keepNode) {
node.changed = true; node.changed = true;