ScrollingFrame with enabled AutomaticSize breaks AutomaticSize of ancestor frame

I need the frame to apply it’s UIPadding with AutomaticSize. But i just notice it doesn’t, because of ScrollingFrame (will be shown below).

As the result it applies the size of list content, but not the padding (highlighted) itself.

The reason why did i suspect ScrollingFrame, is that the padding applied completely fine without it. Which is weird.


Here’s the hierarchy, and UIPadding that should be applied by logic
image

All i need is find the way to return the padding without getting rid of automatic size calculations. Well i could use “Magic number” for frame’s size, but that’s not the ideal option…

Here’s file, if it’s needed:
CollectionFrame.rbxm (10.7 KB)

You should turn on the AutomaticCanvasSize instead of AutomaticSize for the ScrollingFrame I think

it acually is already, set on “Y”.
and AutomaticSize set on “X”

Your UIPadding might be the problem because it looks fine without the UIPadding (The one parented to Collection frame)

well i need the padding anyway

Your magic size for your collection frame X offset is 692

The Collection’s UIPadding.PaddingRight seems to not be working so I think we are going to try to mimic the PaddingRight by calculating Collection’s Size.X

(Btw, I will use offset because I only see you using offset)

To find that Collection X size, we know what the X size of the elements within:
_Collection.UIPadding.PaddingLeft.Offset + Collection.UIPadding.PaddingRight.Offset

_Collection.UIListLayout.Padding.Offset * 1 (It looks like you use it to space Grid and Info one time only, so I multipled by 1 or you can just remove 1)

_Grid.UIGridLayout.CellPadding.X.Offset * 3 + Grid.UIGridLayout.CellSize.X.Offset * 4 (I multiplied by 4 because I see that you only use 4 boxes in each row and 3 padding between 4 boxes)

_Grid.UIPadding.PaddingLeft.Offset + Grid.UIPadding.PaddingRight.Offset

_Info.Size.X.Offset

_UIStroke.Thickness * 3

Then you sum all of it together to get X Size

not even universal way, but yeah it works.

i tried to avoid additional scripts that manually calculate the size, but that’s definitely an option i can use while there’s no better solution

Since the calculations above is too messy, we can also just calculate it by using Grid Size and Info Size:
Grid.Size.X.Offset + Info.Size.X.Offset
Collection.UIListLayout.Padding.Offset
Collection.UIGridLayout.PaddingLeft.Offset + Collection.UIGridLayout.PaddingRight.Offset
UIStroke.Thickness

Ok, so. I’ve solved the problem in the worst way possible.
It’s “the worst” not because it doesn’t work, but because it’s not the case i really expected.

Ok, fine, screw it.
Now to the point what i’ve done for the solve…

Previously, i didn’t want to write additional scripts that will handle the size, but seems like i have no choice in the end. So right now, i check for elements added/removed and “AbsoluteContentSize” change.

local Scrolling = script.Parent
local UIGridLayout = Scrolling:FindFirstChildOfClass("UIGridLayout")
local UIPadding = Scrolling:FindFirstChildOfClass("UIPadding")

function Update()
	Scrolling.Size = UDim2.new(
		UDim.new(0,UIGridLayout.AbsoluteContentSize.X) + UIPadding.PaddingRight + UIPadding.PaddingLeft, 
		UDim.new(1,0)
	)
end

Scrolling:GetPropertyChangedSignal("AbsoluteCanvasSize"):Connect(Update)
Scrolling.ChildAdded:Connect(Update)
Scrolling.ChildRemoved:Connect(Update)

Scrolling.AutomaticSize = Enum.AutomaticSize.None

image

It works i guess…