vis-network icon indicating copy to clipboard operation
vis-network copied to clipboard

deselectNode event reports nodes, not nodeIds, in previousSelection

Open micrology opened this issue 2 years ago • 3 comments

The documentation for the deselectNode event states that the property returned includes an array of nodeIds for the nodes previously selected:

previousSelection: {
    nodes: [Array of previously selected nodeIds],
    edges: [Array of previously selected edgeIds]
  }

However, using version 9.1.0, the array is not of nodeIds, but of nodes, for example:

console.log(props.previousSelection.nodes)
[Node1]
0: Node1 {options: {…}, globalOptions: {…}, defaultOptions: {…}, body: {…}, edges: Array(3), …}
length: 1
[[Prototype]]: Array(0)

micrology avatar Jan 17 '22 15:01 micrology

I see this now as well. My first thought was "great, more info", but clearly this would break people's code if it was just looking for the id, and is just wholly unnecessary. Did you find the relevant code that causes this?

nickchomey avatar Mar 25 '22 18:03 nickchomey

Line 18179 of vis-network/esnext/esm/vis-network.js

micrology avatar Mar 25 '22 21:03 micrology

That path doesn't map onto what I've got, but I just submitted this pull request with a fix. You can check the actual file change as well as the code I provided in the comment which I used directly in my vis-network.min.js file.

https://github.com/visjs/vis-network/pull/1734

nickchomey avatar Mar 25 '22 21:03 nickchomey