Disabling UndoManager causes tx in modelChange to return null

Hello!

After spending some time debugging, I have finally figured out why my tx is returning null.

Here is a snippet of the tx code for modelChange

    function modelChanged(evt: any): void {
      if (!evt.isTransactionFinished) return
      const tx: any = evt.object
      console.log('tx', tx)
      if (!tx) return

Why is it if I set undoManager to false, tx returns null? Is there a way to have undoManager turned off but still have transaction events fire?

I assume you are asking when you set UndoManager.isEnabled to false, (or don’t set it because it is disabled by default), why there isn’t a Transaction recorded? Well, I hope the answer is self-explanatory.

But you can get what you want by enabling the UndoManager and setting UndoManager.maxHistoryLength to zero.

Hi Walter!

Thank you! I actually found the same issue on a github post where you answered!

Setting maxHistoryLength indeed fixed the issue! I also found where JonatanGarciaClavo said he would add information regarding this. It was added under the GoJS with React page. Unfortunately since I am using Vue I did not think to look at the React page. Is it possible to add

Note that the UndoManager should always be enabled to allow for transactions to take place, but the UndoManager.maxHistoryLength can be set to 0 to prevent undo and redo.

to the Basics page as well?

Which “Basics” page do you mean? Thanks for pointing out wherever we’re missing some information in our documentation – we’re continually trying to improve it.

This page: GoJS Introduction -- Northwoods Software. And no problem!

I think we don’t want to overload the beginning user with too much detail on that intro page. But we could mention it in the page about transactions: GoJS Transactions -- Northwoods Software And maybe in some other pages too.