goJS behaviour when copying links without nodes


I would like to understand a specific behaviour when copying links in goJS, I hope you can help me:

If I select a link (which is connecting two nodes), copy it to the clipboard using Ctrl + C and pasting it into the diagram using Ctrl + V, the link is not inserted because it would be unconnected, which is fine.

However, the modelChanged listener gets an Insert ChangedEvent and a Delete ChangedEvent. I assume this is intended behaviour?

Also, the “newValue” of the Insert ChangedEvent contains the details of the copied link. The from and to properties are undefined and the fromPort and toPort are set. Is this the standard behaviour or is there some issue in my code?

Yes, that is all expected behavior.

Okay, thanks for the feedback!

I didn’t expect the insert/delete ChangeEvents in this case and this caused a bug in our software, especially as this situation only occurs when trying to copy a link without the attached nodes.

I will check if the from and to properties are set in the Insert ChangedEvent to filter out the irrelevent links.

The disconnected link data object is in the clipboard, so when pasted it will be copied and added to the model. Then the policy is applied about what to do with such data. That separate step causes the Remove change.