I am using gojs with gojs-react with state sync between the react state and gojs implemented using handleModelChange incrementalChange event.
The scenario I am facing is -
I have nodes and links added using diagram.commit then synced up to the react state with skipsDiagramUpdate set to true in handleModelChange.
Now say we added nodes - A and B and links A->B and B->C
NOTE: Node C is not added to the diagram at this point.
Later we add Node C using diagram.commit expecting the B->C will now show up but it is not showing.
I checked both the GoJS links using findLinkByExample the B->C exists and also in the react-state. But, the link isn’t showing in canvas.
Any idea or debug technique will be of immense help here.
I do not understand. You say the user added a link from B to C. Then the user adds C again. How is that possible unless the user deletes C first, causing that link to be removed? I suppose an undo will cause both the C node and B->C link to reappear.
If the user adds a new node like C, the diagram cannot presume to know to automatically add a link from B to new C. But you could implement that policy if you want. Just think about what you should do if there are several nodes like C or like B.
Within one transaction, we go to considerable trouble to make that expectation true.
But over multiple transactions, that is not the case. After all, if there can be partially or completely disconnected links for arbitrarily long times, why should the addition of a node that a link had been connected with cause an automatic connection with that node? I’ll investigate the possibilities.
Ah, the problem is that the implementation of Model.mergeNodeDataArray is clearing all of the unresolved references, under the assumption that the whole collection of nodes is known at that time. The same is true for the Model.nodeDataArray property setter.
We will change that behavior for the next release, 2.1.30. I hope next week.