ScrollingFrame.AutomaticCanvasSize not working with UIListLayout and/or AutomaticSized Children

I’m trying to make a menu with a UIListLayout. (Attached: AutomaticCanvasSizeExample.rbxm) The ScrollingFrame’s AutomaticCanvasSize will only set itself to the WindowSize instead of taking into account its children’s AbsoluteSizing and AbsolutePositioning, resulting in no scrollbar whatsoever. (Attached: IMG1,IMG2, IMG3)

If I remove the UIListLayout and adjusts the children’s positioning manually, the scrolling frame works as intended but STILL does not take into account the AbsoluteSize of its children, resulting in the ScrollingFrame’s CanvasSize not being tall enough to show the last child frame in the order. (Attached: IMG4)

If I had to guess where the issue lies, I would think that it mainly roots from ScrollingFrame.AutomaticCanvasSize not calculating based on AbsoluteSize/AbsolutePosition and instead calculates on children Positioning/Size. (Which ends up being 0 for both AutomaticSized GuiObjects and GuiObjects positioned by UIListLayout.)

If I had to suggest a solution to the CanvasSize issue, it should be calculating based on it’s children’s AbsolutePositioning and AbsoluteSize.
And for the issue of CanvasSize with UIListConstraints, it should be calculating the CanvasSize based off of the UIListLayout.AbsoluteContentSize X/Y depending on the selected AutomaticCanvasSize Axis.





AutomaticCanvasSizeExample.rbxm (13.4 KB)

6 Likes

Thanks for the report! We’ve filed a ticket to our internal database, and we’ll follow up when we have an update for you.

3 Likes

Similar issue, AutomaticSize is not respecting UIPadding and content size.

2 Likes

Whoops, I initially made this as a DM since I couldn’t post to Studio Bugs. I didn’t know that this DM would get turned into a thread. That’s pretty neat though.

Since I determined it was a studio bug, I’ve just been using a quick/easy workaround and thought I should share it for anyone else having this specific issue of ScrollingFrames not adjusting AutomaticCanvasSize properly with UILayouts/UIPadding.

local AllChildren = ScreenGUI:GetDescendants()
for i,v in pairs (AllChildren) do 
	if v:IsA("ScrollingFrame") then 
		if v:FindFirstChildOfClass("UIListLayout") or v:FindFirstChildOfClass("UIGridLayout")then
			local Layout = v:FindFirstChildOfClass("UIListLayout") or v:FindFirstChildOfClass("UIGridLayout")
			local function UpdateSize(FrameInstance,LayoutInstance)
				if FrameInstance and LayoutInstance then
					local PaddingX = 0
					local PaddingY = 0
					if FrameInstance:FindFirstChildOfClass("UIPadding") then
						local UIPadding = FrameInstance:FindFirstChildOfClass("UIPadding")
						PaddingX += UIPadding.PaddingLeft.Offset
						PaddingX += UIPadding.PaddingRight.Offset
						PaddingY += UIPadding.PaddingBottom.Offset
						PaddingY += UIPadding.PaddingTop.Offset
					end
					if FrameInstance.AutomaticCanvasSize == Enum.AutomaticSize.Y then
						FrameInstance.CanvasSize = UDim2.new(0,0,0,LayoutInstance.AbsoluteContentSize.Y + PaddingY)
					elseif FrameInstance.AutomaticCanvasSize == Enum.AutomaticSize.X then
						FrameInstance.CanvasSize = UDim2.new(0,LayoutInstance.AbsoluteContentSize.X + PaddingX,0,0)
					elseif FrameInstance.AutomaticCanvasSize == Enum.AutomaticSize.XY then
						FrameInstance.CanvasSize = UDim2.new(0,LayoutInstance.AbsoluteContentSize.X + PaddingX,0,LayoutInstance.AbsoluteContentSize.Y + PaddingY)
					end
				end
			end
			UpdateSize(v,Layout)
			Layout.Changed:connect(function() UpdateSize(v,Layout) end)
			v:GetPropertyChangedSignal("AutomaticCanvasSize"):connect(function() UpdateSize(v,Layout) end)
		end
	end
end

If you’re having the issue of ScrollingFrames AutomaticCanvasSize not calculating correctly with AutomaticSized descendants, I’ve found the only solution is to calculate the AbsoluteContentSize of all the ScrollingFrame’s children.
You could create a script to automatically calculate the AbsoluteContentSize by comparing AbsolutePositions and AbsoluteSizes between all of its children (which would be relatively straight forward but could be especially hard if you have any positional spacing since the spacing would need to be compared against each child’s AbsoluteSize/AbsolutePosition and could even require annoying conversions if using a mixture of scales and offsets).
I decided not to make that AbsoluteContentSize calculator since it would be very tedious to write and it’s much easier to just grab the already calculated AbsoluteContentSize from a UILayout with the script I posted above. But unfortunately that solution isn’t going to work for you if your use-case doesn’t utilize UILayouts.
You always could do some simple addition/multiplication if you know that the scrolling frame’s children aren’t going to be changing position and/or size but that would defeat the point of using AutomaticCanvasSize since you would end up setting it manually lol.

2 Likes

This bug is STILL an issue that hasn’t been fixed, making this property still borderline useless, since in a ton of use cases where this property shines involves using it in conjunction with a UIListLayout, UIGridLayout, etc.

This same bug report, posted a year ago (AutomaticCanvasSize is borderline useless in its current state) in which they said a “high priority ticket” has been filed, has not resulted in this bug being fixed after a full year.

This is still severely impacting my UI workflow and adds to the list of the flaws that the current UI system has, which has made me spend more time than I need to to research and implement a workaround. I, and a lot of other developers would love an update on this and a fix to end this issue once and for all.

13 Likes

For myself, AutomaticCanvasSize with UIListLayout works about 90% of the time, but for the other 10%, the scroll bar will not be there. This is extremely annoying and destroys the entire usage of this property. In any other situation, I would just hardcode the scale/offset of the frame. This is ONLY useful with UIConstraints, and those are what it doesn’t work with.

Every developer who works with UI that I know has been complaining about this bug. It has been over a year since this was reported. Where is a fix? This must be impacting loads of games.

1 Like

This is a really important issue and hasn’t been fixed yet, not only does using scale/offset determine changes but uilistlayout padding is not supported!

1 Like

I don’t want to be the one to necro a thread, but this issue is still prevalent and very irritating.

1 Like

The engineers will start fixing this issue as soon as possible!

Thank you for your patience!

2 Likes