What’s happening is that the Diagram.layout, which is a LayeredDigraphLayout, is being invalidated because the size of one if its nodes changed due to its expanding or collapsing.
Try setting either Layout.isOngoing to false on your Layout or Part.layoutConditions on your Group. Read about this topic at GoJS Layouts -- Northwoods Software.