Skip to content
This repository was archived by the owner on Jul 13, 2025. It is now read-only.

Commit 9ef638b

Browse files
committed
Text wrapping for list items
1 parent 3fa2d60 commit 9ef638b

File tree

4 files changed

+36
-14
lines changed

4 files changed

+36
-14
lines changed

src/Components/ListItem.lua

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ function Item:render()
2020
local ignoresMenuOpen = props.ignoresMenuOpen
2121
local isHover = self.state.Hover and (not props.menuOpen or ignoresMenuOpen)
2222
local indent = props.Indent or 0
23-
local height = props.Height or 26
2423

2524
local state = Enum.StudioStyleGuideModifier.Default
2625
if props.Active or props.SemiActive then
@@ -31,11 +30,15 @@ function Item:render()
3130

3231
local sourceText = if props.textKey then tr(props.textKey, props.textArgs) else props.Text
3332

33+
local widthUsedUp = 48 + 16 + indent + 3
34+
if props.onSetVisible then
35+
widthUsedUp += 16 + 5
36+
end
37+
3438
return Roact.createElement(ListItemChrome, {
3539
LayoutOrder = props.LayoutOrder,
3640
hidden = props.Hidden,
3741
state = state,
38-
height = height,
3942
showDivider = props.ShowDivider,
4043

4144
mouseEnter = function(_rbx)
@@ -55,15 +58,24 @@ function Item:render()
5558
}, {
5659
StudioThemeAccessor.withTheme(function(theme)
5760
return Roact.createElement("Frame", {
58-
Size = UDim2.new(1, 0, 1, 0),
61+
Size = UDim2.fromScale(1, 0),
62+
AutomaticSize = Enum.AutomaticSize.Y,
5963
BackgroundTransparency = 1.0,
60-
Position = UDim2.new(0, 0, 0, 0),
6164
}, {
65+
Layout = Roact.createElement("UIListLayout", {
66+
SortOrder = Enum.SortOrder.LayoutOrder,
67+
}),
6268
TopElements = Roact.createElement("Frame", {
69+
LayoutOrder = 1,
6370
BackgroundTransparency = 1,
64-
Size = UDim2.new(1, -indent, 0, 26),
65-
Position = UDim2.new(0, indent - 10, 0, 0),
71+
Size = UDim2.fromScale(1.0, 0.0),
72+
AutomaticSize = Enum.AutomaticSize.Y,
6673
}, {
74+
Padding = Roact.createElement("UIPadding", {
75+
PaddingTop = UDim.new(0, 3),
76+
PaddingBottom = UDim.new(0, 3),
77+
PaddingLeft = UDim.new(0, indent),
78+
}),
6779
Checkbox = props.Checked ~= nil and Roact.createElement(Checkbox, {
6880
Checked = props.Checked,
6981
Disabled = props.CheckDisabled,
@@ -82,7 +94,8 @@ function Item:render()
8294
BackgroundTransparency = 1.0,
8395
TextXAlignment = Enum.TextXAlignment.Left,
8496
Position = props.Icon and UDim2.new(0, 48 + 16, 0, 0) or UDim2.new(0, 14, 0, 0),
85-
Size = UDim2.new(1, -40, 1, 0),
97+
Size = UDim2.new(1, -widthUsedUp, 0.0, 0),
98+
AutomaticSize = Enum.AutomaticSize.Y,
8699
Text = props.IsInput and (props.TextBoxText or "") or sourceText,
87100
AutoLocalize = false,
88101
ClearTextOnFocus = if props.IsInput then props.ClearTextOnFocus else nil,
@@ -92,6 +105,7 @@ function Item:render()
92105
Font = Enum.Font.SourceSans,
93106
TextSize = 20,
94107
TextColor3 = theme:GetColor("MainText"),
108+
TextWrapped = true,
95109

96110
[Roact.Event.FocusLost] = props.IsInput and function(rbx, enterPressed)
97111
local text = rbx.Text
@@ -108,7 +122,7 @@ function Item:render()
108122
),
109123
Visibility = props.onSetVisible and Roact.createElement(Icon, {
110124
Name = props.Visible and "lightbulb" or "lightbulb_off",
111-
Position = UDim2.new(1, 5, 0.5, 0),
125+
Position = UDim2.new(1, -5, 0.5, 0),
112126
AnchorPoint = Vector2.new(1, 0.5),
113127

114128
onClick = props.onSetVisible,
@@ -129,7 +143,9 @@ function Item:render()
129143
}),
130144
}),
131145
Children = Roact.createElement("Frame", {
132-
Size = UDim2.new(1, 0, 1, -26),
146+
LayoutOrder = 2,
147+
Size = UDim2.fromScale(1, 0),
148+
AutomaticSize = Enum.AutomaticSize.Y,
133149
Position = UDim2.new(0, 0, 0, 26),
134150
BackgroundColor3 = theme:GetColor("MainBackground"),
135151
BorderSizePixel = 0,

src/Components/ListItemChrome.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ local Roact = require(Modules.Roact)
44
local StudioThemeAccessor = require(script.Parent.StudioThemeAccessor)
55

66
local function ListItemChrome(props)
7-
local height = props.height or 26
87
local state = props.state or Enum.StudioStyleGuideModifier.Default
98
local showDivider = props.showDivider
109

1110
local child = Roact.oneChild(props[Roact.Children])
1211

1312
return StudioThemeAccessor.withTheme(function(theme)
1413
return Roact.createElement("TextButton", {
15-
Size = UDim2.new(1, 0, 0, height),
14+
Size = UDim2.fromScale(1, 0),
15+
AutomaticSize = Enum.AutomaticSize.Y,
1616
AutoButtonColor = false,
1717
LayoutOrder = props.LayoutOrder,
1818
Visible = not props.hidden,

src/Components/TagList/Group.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ local function Group(props)
2020
StudioThemeAccessor.withTheme(function(theme, isDarkTheme)
2121
return Roact.createElement("Frame", {
2222
BackgroundTransparency = 1,
23-
Size = UDim2.new(1, 0, 1, 0),
23+
Size = UDim2.fromScale(1, 0),
24+
AutomaticSize = Enum.AutomaticSize.Y,
2425
}, {
26+
Padding = Roact.createElement("UIPadding", {
27+
PaddingTop = UDim.new(0, 3),
28+
PaddingBottom = UDim.new(0, 3),
29+
}),
2530
Visibility = Roact.createElement(Icon, {
2631
Name = "folder_lightbulb",
2732
Position = UDim2.new(1, -4, 0.5, 0),
@@ -36,11 +41,13 @@ local function Group(props)
3641
Text = props.Name,
3742
AutoLocalize = false,
3843
BackgroundTransparency = 1,
39-
Size = UDim2.new(1, -70, 1, 0),
44+
Size = UDim2.new(1, -70, 0, 0),
45+
AutomaticSize = Enum.AutomaticSize.Y,
4046
Position = UDim2.new(0, 20, 0, 0),
4147
TextColor3 = theme:GetColor("MainText"),
4248
TextXAlignment = "Left",
4349
TextSize = 20,
50+
TextWrapped = true,
4451
}),
4552
Arrow = Roact.createElement("ImageLabel", {
4653
Size = UDim2.new(0, 12, 0, 12),

src/Components/TagList/Tag.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ local function Tag(props)
4545
Active = props.isMenuOpen,
4646
Hidden = props.Hidden,
4747
Indent = props.Group and 10 or 0,
48-
Height = props.isMenuOpen and 171 or 26,
4948

5049
onSetVisible = function()
5150
TagManager.Get():SetVisible(props.Tag, not props.Visible)

0 commit comments

Comments
 (0)