Go js group doesnt automatically adjust its dimension wrt to child nodes

Hi Team,

I am woking with gojs group and i have some nodes inside them.

now I have a requirement to collapse and expand a group full of child nodes, so I have wrote a custom function, which filters the nodes and links in the respective group by updating the nodes and links in the model array like below,

 this.diagram.commit((d) => {
      const model = d.model as GraphLinksModel;

      model.mergeNodeDataArray(nodes);
      model.mergeLinkDataArray(links);
    }, 'Update Diagram');

so when I collapse/shrink any group, I filter the child nodes of the respective group, I also adjust the dimension by shrinking the size of the group to a smaller size, so I tried setting the width and height to a fixed value, this works fine.

now when I try to expand/expand such a group, i add back the filtered nodes and links, but I am unable to expand the group’s doesnt adjust its dimensions automatically to contain the all the child nodes, group is not auto-adjusting its height and width with respect to child nodes inside it, instead, it says to the height and width I had fixed it before(when collapsing the group).

solution i tried, I tried to capture the groups height and width before collapsing and use the same value to expand it, which worked in some scenarios, but the group fails to dynamically change its dimension, when a new child node was added.

so any help would be appreciated. @walter

As soon as you have set desiredSize (or width or height) to a real number, it will have that size, no matter the contents.

I’m surprised that you want to set the size explicitly when a group collapses, or when it expands. But if you do set it to a real Size, be sure to reset it to new go.Size(NaN, NaN) when you want it to compute its own natural size.

oh okay, perfect.

thats exactly what i was looking for :)

thanks once again @walter :)