Gui: StackPanel not settings correct width/height when it has invisible child controls

Hi,
I’ve got a horizontal StackPanel which has two vertical StackPanels as child elements.
Both vertical StackPanels have two buttons each.
If I set the visibility of both buttons from the right panel to false, the width of the right panel doesn’t change, althought adaptWidthToChildren is set to true. (it should be 0 in my opinion, the height is correctly set to 0)
On the other hand, if I set the visibility of the right panel itself to false, the root panels width gets updated correctly, and if both vertical stack panels are invisible, the width and height of the root panel is 0.

Of course I could just set the visibility of the corresponding panel itself to false, if I know that all children are invisible, instead of just it’s child controls, but I wanted to know if this is a bug or not.

(same for height, if you switch vertical to horizontal, and the adapt…ToChildren, https://playground.babylonjs.com/#XCPP9Y#12169)

Thanks.

@DarraghBurke hopefully can help with this.

Hi, sorry for the slow response. A fix is in PR: [GUI] Skip invisible or unrenderable children in layout calculations by darraghjburke · Pull Request #12392 · BabylonJS/Babylon.js (github.com)

Thanks for pointing this out!

4 Likes