It works but one side-effect is the selected node goes away plus I’m guessing it’s inefficient. I’m wondering if there is a way to apply the changes from nextProps.nodeDataArray to the current model.nodeDataArray? The only difference between the two is one node will have the name changed but in this code I don’t know which node that is. Any advice on a better way to handle this?
If not then I guess I can get the current selection, do the code above, then re-apply the selection.
Walter I added those calls and my handleModelChange is now getting called on commitTransaction() when it wasn’t before and causing problems. I can’t remember why I didn’t want that called but will look into it. Here is my complete code snippet.
This is my unique key code which again I need to remember why I did it this way (we moved to a monorepo so the commit “Moved to monorepo” doesn’t help me any).
Based on your calls to removeModelChangedListener and addModelChangedListener, I imagine you didn’t want your handleModelChange called because you were trying to prevent update cycles. What happens if you place those calls outside the transaction?
You can also prevent cycles by ensuring the model changes aren’t already reflected in your data via comparison, or maybe using some sort of flag to indicate the GoJS model is being updated with current data and not to execute in the handleModelChange function.
Ok, glad you got it working. I was just referring to checking for changes outside of GoJS in your handleModelChange function, but this method should be fine too.