display: flex doesn't make element visible right away

I have an element with display: none property which I added through selector. At runtime I try to make it visible with display: flex (in Debugger or through C#) but it doesn’t get rendered. To show/hide UI I’m changing document.rootVisualElement.style.display = value ? DisplayStyle.Flex : DisplayStyle.None and after hiding/showing rootVisualElement my element finally gets rendered.
Tested it in HTML/CSS and it works as expected.
Using visibility for this for now, but as I understood it should be slower.

1 Like

It only works though USS selectors. If I have

.box {
    display: none;
}

.box.visible {
    display: flex;
}

and add visible class to .box element at runtime, the engine renders it.

1 Like

Hi RunninglVlan,

Thanks for reporting this.
Do you think it would be possible for you to post your project or small repro case through a bug?

Done, case 1359661

UPDATE: Fixed in Unity 2022.1.0a12 and above