TextWrapped and MultiLine limits automatic sizing of the TextBox, what are the workarounds?

Maybe, one of the workarounds could be Roblox fixing it maybe? :thinking:

Anyways.

The issue is as following.

  1. I put a TextBox inside a ScrollingFrame.
  2. I gave the TextBox the Size of “1,0,1,0”
  3. I changed the colors so that it is a bit more visible, but that doesn’t matter.
  4. I enabled MultiLine for the TextBox
  5. Make sure ClearTextOnFocus is off
  6. Make sure TextWrapped is on
  7. Turn TextScaling off
  8. Change AutomaticSize of the TextBox to Y

Okay, so after that you get a textbox and you can spam the Enter key.

However, while TextWrapping is on, there’s some limitation

It just stops…

And that’s the issue.

And this is why TextLabel | Documentation - Roblox Creator Hub

If further line breaks would cause the vertical height of the text (the Y component of TextLabel.TextBounds ) to exceed the vertical height of the element (the Y component of GuiBase2d.AbsoluteSize ), then that line will not be rendered at all.

So how can I fix this?

I want the TextBox to expand indefinitely vertically, without having to turn on TextScaling and then get super small text.

But TextWrapped seems to prevent me from doing so.

I think Roblox should change its behaviour of not rendering the other lines of the textbox if it goes over Y AbsoluteSize or whatever, while MultiLine is on.

I want to do a proper scrollable text box basically.

6 Likes

Hi @HealthyKarl , thanks for reporting this issue. We are currently working on a fix for this.

4 Likes

Thanks.

Keep it updated on when the fix was published to Roblox Studio.

Hi @HealthyKarl , we’ve recently rolled out a change, please verify on your side if this update fixes the issue you mentioned above (this may require a software update on your RobloxStudio) and let us know, thank you!

I am on Version 0.531.0.5310423 (64bit) and I am still able to reproduce the issue.

It’s not fixed.

Hi @HealthyKarl , could you please provide a place file so that we can verify on our end? I’ll investigate to see if it’s because the update is not published yet or the issue is not fixed.

2 Likes

I have the same issue, it’s not fixed. TextBounds is not properly changing and the Text won’t render.

AbsoluteSize Y is 70, and TextBounds Y is only 47

I figured out a weird fix

I just made a TextLabel copy over the TextBox and copied AbsoluteSize and Text and made the TextBox invisible.

repeat task.wait()
	script.Parent.ScrollingFrame.TextLabel.Text = script.Parent.ScrollingFrame.TextBox.Text
	script.Parent.ScrollingFrame.TextLabel.Size = UDim2.new(1, 0, 1, script.Parent.ScrollingFrame.TextBox.AbsoluteSize.Y)
until false
1 Like

I’m assuming this was never fixed as I’m struggling with the same issue now. Any updates?

(Update: I’ve submitted a new bug for this)

2 Likes

Issue still occurs on my test file.

2 Likes

I’m still experiencing this bug. Any updates?

3 Likes

This seems to affect labels under the TextSize of 34. Use that size or more for now I guess.

There’s going to be a preferred textsize beta feature apparently

I wonder how it will work with automatic sizing and other things

 

Oh I just realized I created this post… Uhhh this was long ago I’d have to find the file again, so I can turn it in a proper Bug Report, since the way Bug Reports work were improved in the past.

I don’t really know if it actually is a bug or just our fault. I’d have to actually test this more but there was some sort of point that this issue had.

2 Likes

no its a bug with scaling, there are multiple and it does still happen
a work around i can think of is making the text box invisible (background and text) and just making it so a normal visible text label behind it updates with its text every time the text of the text box is changed, text labels should scale and wrap nicely
also what im noticing is that when you are not editing the text box it shows multiple lines normally but once you start editing everything gets squished into one line (im not sure if that changed or was always like that) - but what this means for the workaround is that if you leave the text box to auto-scale and wrap also, it will scale correctly when not editing and so you will be able to click on it everywhere where the text should expand

okay i am sorry i bumped this a bunch but i finally found a solution, the reason robloxes wrapping doesnt work is that when automatic size Y is set, it doesnt realize that it has infinite downwards space for text, it treats it as 0 and the wrap property then intentionally doesnt do anything
the best way i found to fix this is to not use automaticc size Y in combination with wrapped text boxes and instead if you need auto Y scaled wrapped text boxes code the automatic scaling yourself like so:

function BetterTextBox(box : TextBox)
	box.TextWrapped = true
	local padding_offset = Vector2.zero
	local padding = box:FindFirstChildOfClass("UIPadding")
	if padding then
		padding_offset += Vector2.new(padding.PaddingLeft.Offset + padding.PaddingRight.Offset, padding.PaddingTop.Offset + padding.PaddingBottom.Offset)
	end
	local last_bounds = 0
	local function update()
		box.RichText = not box:IsFocused() -- remove line if you dont want rich text to work
		local new_bounds = TextS:GetTextSize(box.ContentText, box.TextSize, box.Font, Vector2.new(box.AbsoluteSize.X - padding_offset.X, 99999999))
		if new_bounds == last_bounds then return end
		last_bounds = new_bounds
		box.Size = UDim2.new(box.Size.X, UDim.new(0, new_bounds.Y+padding_offset.Y))
	end
	box.Focused:Connect(update)
	box.FocusLost:Connect(update)
	box:GetPropertyChangedSignal("TextBounds"):Connect(update)
	box:GetPropertyChangedSignal("ContentText"):Connect(update)
end

that function also takes into account any UIPadding instance you have under the TextBox because thats what im doing, it also works with rich text (when you click away) but you can disable that if you want
OH and i alsmost forgot, i used the “legacy” TextService:GetTextSize function instead of the new TextService:GetTextBoundsAsync function because i wanted to avoid the Async part where it has to fetch a font config file from the roblox servers and whatnot. So basically its more reliable but only works for fonts in the old Enum.Font