When using AutomaticSize on a Frame, descendant UI objects with a corresponding non-zero AnchorPoint will result in the parent frame being sized incorrectly. Non-corresponding AnchorPoints behave as expected. This happens in both Studio and in-game.
E.g., Frame A
has a child TextLabel B
. Both are set to have their AutomaticSize set to the X-axis. A
should adapt its length based on the content of B
. However, when B
’s AnchorPoint.X changes to anything besides zero, A
does not account for this and will be sized wildly incorrectly. Likewise, Frame C
has a child TextLabel D
. Both are set to have their AutomaticSize set to the Y-axis. When D
’s AnchorPoint.Y is not set to zero, C
will be sized incorrectly.
In this example, all three Frames have a TextLabel child. All Frames and TextLabels have their AutomaticSize set to X.
The top Frame has a TextLabel child with its AnchorPoint set to {0, 0.5}.
The middle Frame has a TextLabel child with its AnchorPoint set to {0.5, 0.5} and the TextLabel’s position is set to {0, 0},{0.5, 0}.
The bottom Frame has a TextLabel child with its AnchorPoint also set to {0.5, 0.5} and the TextLabel’s position is set to {0.5, 0},{0.5, 0}.
The middle and bottom parent Frames do not account for their TextLabel’s AnchorPoints and are not sized correctly. Setting the TextLabel’s AnchorPoint.X to 0.5 and its Position.X.Scale to 0.5, as in the bottom example, which should center it horizontally in its parent Frame does not fix this. However, non-corresponding AnchorPoints work as expected, such as the top example’s TextLabel having its AnchorPoint set to {0, 0.5} and its Position.Y.Scale set to 0.5, centering it vertically.
System information:
OS: Windows 11
CPU: AMD 5800X
GPU: NVIDIA 3070
RAM: 32GB of DDR4-3600
Reproduction file:
AutomaticSizeBug.rbxl (59.9 KB)
Expected behavior
In cases where descendants are smaller than the parent’s minimum size, I believe the AnchorPoint should be respected and act as a normal parent/child. This allows for situations where you want child elements to be anchored to a specific part of a parent Frame until the child grows too large.
In cases where the parent must be resized to fit the child, AutomaticSize should ignore the AnchorPoint. As an easier but less neat solution, when AutomaticSize is enabled, its descendants corresponding AnchorPoints should always be ignored, regardless of size.
I understand this is a rather low-impact bug and will probably take quite a while to fix. In the mean time, I hope this behavior is at least documented under GuiObject.AutomaticSize and/or the UI/Size Modifiers documentation, because this took a lot of head-scratching to realize what was going on, especially as the Size Modifiers article explicitly mentions respecting AnchorPoints.