NorthwoodsSoftware / GoJS

JavaScript diagramming library for interactive flowcharts, org charts, design tools, planning tools, visual languages.
http://gojs.net
Other
7.7k stars 2.86k forks source link

copySelection exception when the selection contains links #210

Closed aspirio187 closed 4 months ago

aspirio187 commented 4 months ago

Hi,

After using e.diagram.commandHandler.selectAll(), which will select links and nodes, if you try to use the function e.diagram.commandHandler.copySelection(). The app will crash and display this error:

Cannot read properties of null (reading 'iteratorValues')
TypeError: Cannot read properties of null (reading 'iteratorValues')
    at CommandHandler.copyToClipboard (http://localhost:3000/static/js/bundle.js:56218:139)
    at CommandHandler.copySelection (http://localhost:3000/static/js/bundle.js:56193:14)
    at click (http://localhost:3000/static/js/bundle.js:482:36)
    at ContextMenuTool.JD (http://localhost:3000/static/js/bundle.js:47674:28)
    at ContextMenuTool.standardMouseClick (http://localhost:3000/static/js/bundle.js:47627:39)
    at ContextMenuTool.doContextClick (http://localhost:3000/static/js/bundle.js:50687:135)
    at ContextMenuTool.doMouseUp (http://localhost:3000/static/js/bundle.js:50679:12)
    at Diagram.doMouseUp (http://localhost:3000/static/js/bundle.js:52724:24)
    at i.ha (http://localhost:3000/static/js/bundle.js:52658:319)

I tried to only select nodes and copy, it does work. It is however, possible to select all and remove.

I am using GoJS with ReactJs.

The parameters allowCopy, allowDelete and allowLink are all set to true during diagram initialization.

// set your license key here before creating the diagram: go.Diagram.licenseKey = "...";
const diagram = new go.Diagram({
  allowCopy: true,
  allowDelete: true,
  allowLink: true,
  initialAutoScale: go.AutoScale.UniformToFill,
  ...
})
simonsarris commented 4 months ago

Thanks for reporting this. What version of GoJS are you using?

simonsarris commented 4 months ago

We've been able to reproduce this. A fix will be out with the next version, released probably some time in the coming week.

aspirio187 commented 4 months ago

Collaborator

I am using the following npm packages:

"gojs": "^3.0.1",
"gojs-react": "^1.1.2",
simonsarris commented 4 months ago

This has been fixed in 3.0.2, which we just released. Thank you for reporting it.