Auto layout positioned not work when model get updated

Hi, Admin, we are using GojsDiagram from ‘react-gojs’. The first time loading a diagram is OK of auto layout. But after removing a node from the diagram and the ‘onModelChange’ triggered, then the updated mode passed to GojsDiagram, the layout get messy.
Do you have any idea to fix this issue?

I really cannot tell what is going on in your app. How is the node being removed? That should cause some model changed events, including one at the end of the transaction that should update the props state. But that should not cause a diagram update to happen, since the diagram (model) was what caused the update.

@walter, it turned out that it’s caused by ‘key’ issue. And now I am going to provide my own ‘makeUniqueKeyFunction’ and set ‘copiesKey’ to false, but I don’t see a way in ‘gojs-react’.

Could you pls give me some ideas?

When you first set up the Diagram, including its templates, you also have to set up its initial empty Diagram.model. At that time you can set properties such as Whenever a model is created in memory you will need to make sure such functional properties (or method overrides) are set up.

This is demonstrated in

1 Like

Thank you, Walter. That’s what I’ve missed in the documentation.
I’ve also figured out our defect was caused by our React adapter which hasn’t provide the support of customization of setting ‘copiesKey’ to false.
We will use your official React adapter for our project soon.