Hello. Why TemplateContainer with absolute position is moved around by its parent’s Justify Content setting if it’s set to Space Around or Space Evenly? Tested in 6000.0.26f1
How to reproduce:
-
Create a UI Document for TemplateContainer
-
Create a TemplateContainer from VisualTreeAsset, something like this:
_templateContainer = _asset.Instantiate();
_templateContainer.style.position = Position.Absolute;
_templateContainer.style.width = new StyleLength(new Length(100, LengthUnit.Percent));
_templateContainer.style.height = new StyleLength(new Length(100, LengthUnit.Percent));
_templateContainer.style.display = DisplayStyle.None;
-
Create UIDocument with VisualElement inside. Set that visual element to Justify Content - Space Around. Add two buttons inside (just for visual):
-
Add our _templateContainer to the VisualElement (I do this at runtime):
_uiParent = _ourUIDocument.rootVisualElement.Q<VisualElement>("TopVisual");
_uiParent.Add(_templateContainer);
_templateContainer.style.display = DisplayStyle.Flex;
-
_templateContainer position is equal to the first button position (affected by Justify Content of the VisualElement):
If you turn off some buttons from the UI Toolkit Debugger, it will also move the Template Container to the next available button. At runtime. So, as a result, the element with absolute position is moved around by its parent’s settings and by other children of its parent hierarchy.
Is this intentional (and kind of weird) or is it a bug?