(Engine bug) 3.8.5 potential bug with cc.Layout component

Hi, I have just created a new node with Layout component using Creator 3.8.5

Adding chilren in Editor and the children are auto arranged as expected

Using code to add chilren at runtime (or toggling children active/inactive) doesn’t cause the layout to be auto arranged.
Even calling Layout.updateLayout() doesn’t work

Could you the Engine developers please check out?
Thanks!

Could you post your code and show your Layout component setup?

I tried to replicate the bug on a brand new project but it didn’t occur.
After a while debugging I have found the reason!

I added children to the Layout node when it’s active = false
I called director.pause() right before calling Layout.active = true. The pause command stopped the layout component from rearranging its children

I don’t know if it can be called an engine bug, but it could be pretty popular when the game devs try to show/hide some dialogs on game pause/resume. And some of the dialogs might contain cc.Layout

My case is special because it rendered the children “in the dark” when the dialog was not active.


The test code

import { _decorator, Component, director, find, instantiate, Layout, log, Node, sp, UITransform, v3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('NewComponent')
export class NewComponent extends Component {

    onLoad() {
        const sampleNode = find('Canvas/a');
        const container = find('Canvas/layer_select_character/Layout');

        for (let i = 0; i < 3; i++) {
            const newNode = instantiate(sampleNode);
            container.addChild(newNode);
            newNode.active = true;
        }
        container.getComponent(Layout).updateLayout();

        find('Canvas/button_pause').on(Node.EventType.TOUCH_START, () => {
            container.parent.active = true;
            director.pause();
        });

        find('Canvas/button_resume').on(Node.EventType.TOUCH_START, () => {
            director.resume();
        });
    }

}