From 5cf44a25dc6db9af8a7a87efad598fa8a8dea093 Mon Sep 17 00:00:00 2001 From: nickchomey <88559987+nickchomey@users.noreply.github.com> Date: Fri, 25 Mar 2022 15:53:24 -0600 Subject: [PATCH 1/3] previous selection returned entire object vs ids Previous selection was returning the entire node and edge objects rather than just an array of ids. This fixes it. I only tested it via modifying the vis-network.min.js file directly, but have translated it back to this format. Please check and improve as necessary. ` value: function (g, A) { var t = !1, e = this._selectionAccumulator.commit(), C = {}, nodes = [], edges = []; for (let i = 0; i < e.nodes.previous.length; i++ ){ nodes.push(e.nodes.previous[i].id); }; for (let i = 0; i < e.edges.previous.length; i++ ){ edges.push(e.edges.previous[i].id); }; C = { nodes: nodes, edges: edges }; ` --- lib/network/modules/SelectionHandler.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/network/modules/SelectionHandler.js b/lib/network/modules/SelectionHandler.js index 2666baa436..9144ac0979 100644 --- a/lib/network/modules/SelectionHandler.js +++ b/lib/network/modules/SelectionHandler.js @@ -554,9 +554,20 @@ class SelectionHandler { let selected = false; const selectionChanges = this._selectionAccumulator.commit(); - const previousSelection = { - nodes: selectionChanges.nodes.previous, - edges: selectionChanges.edges.previous, + const previousSelection = {}; + var nodes = []; + var edges = []; + + for (let i = 0; i < selectionChanges.nodes.previous.length; i++ ){ + nodes.push(selectionChanges.nodes.previous[i].id); + }; + for (let i = 0; i < selectionChanges.edges.previous.length; i++ ){ + edges.push(selectionChanges.edges.previous[i].id); + }; + + previousSelection = { + nodes: nodes, + edges: edges }; if (selectionChanges.edges.deleted.length > 0) { From b7839ba3b1a15c482fd4d373c7de278f93780fbb Mon Sep 17 00:00:00 2001 From: nickchomey <88559987+nickchomey@users.noreply.github.com> Date: Tue, 29 Mar 2022 14:55:14 -0600 Subject: [PATCH 2/3] implement code suggestion from @micrology --- lib/network/modules/SelectionHandler.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/lib/network/modules/SelectionHandler.js b/lib/network/modules/SelectionHandler.js index 9144ac0979..788640e430 100644 --- a/lib/network/modules/SelectionHandler.js +++ b/lib/network/modules/SelectionHandler.js @@ -554,20 +554,10 @@ class SelectionHandler { let selected = false; const selectionChanges = this._selectionAccumulator.commit(); - const previousSelection = {}; - var nodes = []; - var edges = []; - - for (let i = 0; i < selectionChanges.nodes.previous.length; i++ ){ - nodes.push(selectionChanges.nodes.previous[i].id); + const previousSelection = { + nodes: selectionChanges.nodes.previous.map(node => node.id), + edges: selectionChanges.edges.previous.map(edge => edge.id), }; - for (let i = 0; i < selectionChanges.edges.previous.length; i++ ){ - edges.push(selectionChanges.edges.previous[i].id); - }; - - previousSelection = { - nodes: nodes, - edges: edges }; if (selectionChanges.edges.deleted.length > 0) { From d52738299874b75ac66e0d862cfc0f0bea6e1bb1 Mon Sep 17 00:00:00 2001 From: nickchomey <88559987+nickchomey@users.noreply.github.com> Date: Tue, 29 Mar 2022 14:55:43 -0600 Subject: [PATCH 3/3] . --- lib/network/modules/SelectionHandler.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/network/modules/SelectionHandler.js b/lib/network/modules/SelectionHandler.js index 788640e430..b4e486c696 100644 --- a/lib/network/modules/SelectionHandler.js +++ b/lib/network/modules/SelectionHandler.js @@ -556,8 +556,7 @@ class SelectionHandler { const selectionChanges = this._selectionAccumulator.commit(); const previousSelection = { nodes: selectionChanges.nodes.previous.map(node => node.id), - edges: selectionChanges.edges.previous.map(edge => edge.id), - }; + edges: selectionChanges.edges.previous.map(edge => edge.id), }; if (selectionChanges.edges.deleted.length > 0) {