Issue
If a user is selecting a TextBox when it’s parented to nil (not destroyed), the Text property is cleared, even when TextEditable is set to false!
System Info
Intel(R) Core™ i9-10850K CPU @ 3.60GHz
16GB Ram
NVIDIA GeForce RTX 3090 Ti
Reproduction
Code
local screenGui = Instance.new("ScreenGui", game.StarterGui)
local textBox = Instance.new("TextBox", screenGui)
textBox.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
textBox.TextColor3 = Color3.fromRGB(204, 204, 204)
textBox.Size = UDim2.fromOffset(200, 50)
textBox.TextSize = 16
-- Text is uneditable
textBox.ClearTextOnFocus = false
textBox.TextEditable = false
textBox.Text = "Please Select Me!"
task.wait(1)
print("SELECTING")
textBox:CaptureFocus()
-- Highlighting the text to make the selection more visible.
-- This is just for a visual indicator, and disabling this
-- does not change the behavior of the bug.
do
textBox.CursorPosition = #textBox.Text + 1
textBox.SelectionStart = 1
end
task.wait(1)
print("UNPARENTING")
textBox.Parent = nil
print("PARENTING")
textBox.Parent = screenGui
task.wait(2)
screenGui:Destroy()
Example
In a few of my plugins, I cull a ScrollingFrame’s children depending on whether they’re in view or not. In this case, my plugin has select-able TextBoxes to copy color values from, which if scrolled off-screen while selected are completely cleared.

Expected behavior
I expect the TextBox to be unfocused as usual, with no change to the Text property.