Invalid ScrollingFrame.CanvasPosition values are permitted when scroll bar is present on the same axis

It seems that when a scrollbar is present on one axis, the ScrollingFrame’s (internal) CanvasSize is expanded on that axis to cover the entire screen. When this happens, the engine allows the ScrollingFrame to be scrolled slightly, which is incorrect because the CanvasSize property set by the developer may be too small to allow any scrolling at all. The amount of scrolling allowed seems to be based on the width of the scroll bar.

This causes undesirable behavior when code is trying to manually apply changes to CanvasPosition (the canvas gets stuck in a scrolled position even when no scrolling is allowed, and the player cannot reset the canvas position), and when the player is using touch input (because they are allowed to scroll in an incorrect direction).

For example, using the code below, I got this screenshot which demonstrates the problem. Note how AbsoluteCanvasSize differs from the CanvasSize property.

local Gui = Instance.new("ScreenGui")
Gui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
Gui.ResetOnSpawn = false

local ScrollingFrame = Instance.new("ScrollingFrame")
ScrollingFrame.CanvasSize = UDim2.new(20, 0, 0, 30)
ScrollingFrame.Size = UDim2.fromScale(0.5, 0.5)
ScrollingFrame.Position = UDim2.fromScale(0.5, 0.5)
ScrollingFrame.AnchorPoint = Vector2.new(0.5, 0.5)
ScrollingFrame.BackgroundColor3 = Color3.new(0.3, 0.3, 0.3)
ScrollingFrame.Parent = Gui

(You should manually play around with the CanvasPosition property to see how it behaves.)

1 Like

This is just an acknowledgment announcement!

We’ve filed a ticket to our internal database, and we’ll follow up when we have an update!

Thanks for the report!