Vue 2 - Org Chart - Event (Initial Layout) - Unable to Fetch Object in Event

Versions: Go.js 2.1.33 & Vue 2 & Nuxt 2
Issues: It is exiting the listener for initial layout / MakeUniqueKey Function and the object gets set to null. Not sure why it returns null object in event.
Code: Add Model Change Listener
orgDiagram.addModelChangedListener(function (evt) {
if (!evt.isTransactionFinished) return;
var txn = evt.object;
Where Object comes with expanded keys

Where it clears object: (after evt.isTransactionFinished check)

Similar implementation - Same code but event doesn’t show null in object while starting transaction.

Not sure how it works in one place but doesn’t in another when the code is same.
Please do help me in understanding the root cause here. Thanks in advance.

I’m not sure what problem you are trying to show.

It is certainly the case that a transaction could execute but there are no ChangedEvents that happen. That could cause there not to be any Transaction, so the ChangedEvent.object for the “Transaction” type ChangedEvent would be null.

I am trying to track the expanded keys using the object that is coming in the event.

When it says the transaction isn’t finished and then tracks the next change - “StartingFirstTransaction” it shows object as null. But shows the object in ‘MakeUniqueKey’. How can same event in same feature (implemented in two different places) return null in one implementation and object in another?

Refer Here: Changed Events | GoJS

There are a number of “Transaction” type ChangedEvents that are almost always ignored. I suggest that you set a breakpoint just after the second return conditional statement.

And you shouldn’t set self.isModalOpen until immediately after that second return check. Setting it before that means it will get set without the execution of the rest of the code there when ChangedEvent.object is null because there were no recorded changes during the transaction so no Transaction was created to remember them.

1 Like