Force Nodes to be always on top when expanding a group

Hi,
When i expand a group, i want its nodes to be at the topmost layer and overlap other nodes.
I tried layerName=“Foreground” / zOrder += 200, but it looks like it does not work all the time.
Is there any elegant way to “move” the group nodes to the top most layer, when the group is expanded ?
Regards
Tany

Does this event handler in your group template(s) do what you want? Don’t use Part.zOrder at all.

        subGraphExpandedChanged: g => {
          if (g.isSubGraphExpanded) {
            g.layerName = "Foreground";
            g.findSubGraphParts().each(p => { p.layerName = "Foreground"; p.layerName = ""; });
            g.layerName = "";
          }
        }

The critical point is that the member Parts of a Group are independent Parts, so they can be in whatever layer you like. So you have to explicitly change the layers for all of those parts.

I also put everything back in the default layer, so that everything doesn’t just accumulate in the “Foreground” layer.

OK,
What does it mean { p.layerName = “Foreground”; p.layerName = “”; }) ?
It looks like you set the part layer to “Foregroud” and immediately unset it…
By the way, the group parts include links as well ?

That’s just to make sure the parts are added to the end of the list of Parts in the default Layer.

Yes, that includes Links.

Did you have a problem using that code in your app?

It works fine.
By the way,
do i have to do the opposite when the group is collapsed ?
In other words, do i have to put p.layerName = “” for all parts ?

If the member nodes are not visible because the containing group is collapsed, they cannot effect the visual order that nodes are drawn.