From ed4b98b5982720ea005bc1fcf433d01ccb2bddc6 Mon Sep 17 00:00:00 2001 From: GogoVega <92022724+GogoVega@users.noreply.github.com> Date: Wed, 26 Jun 2024 09:22:01 +0200 Subject: [PATCH] Fix adding users to history if multiple props modified --- .../editor-client/src/js/ui/editor.js | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js b/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js index c6a448dd3..1bdd134fb 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js @@ -1534,6 +1534,7 @@ RED.editor = (function() { if (scope) { const newUsers = editing_config_node.users.filter(function (node) { let keepNode = false; + let nodeModified = null; for (const d in node._def.defaults) { if (node._def.defaults.hasOwnProperty(d)) { @@ -1544,15 +1545,19 @@ RED.editor = (function() { // this config node in the correct scope. keepNode = true; } else { - historyEvents.push({ - t: "edit", - node: node, - changes: { [d]: node[d] }, - changed: node.changed, - dirty: node.dirty - }); + if (!nodeModified) { + nodeModified = { + t: "edit", + node: node, + changes: { [d]: node[d] }, + changed: node.changed, + dirty: node.dirty + }; + } else { + nodeModified.changes[d] = node[d]; + } - // Remove the reference to the config + // Remove the reference to the config node 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 if (!keepNode) { node.changed = true;