-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Long text in Select boxes overflows out of the box #2522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
So I think I figured out a potential fix, just adding TextTruncate wrapping to the RichText widget in the renderer.
func (s *Select) CreateRenderer() fyne.WidgetRenderer {
s.ExtendBaseWidget(s)
s.propertyLock.RLock()
icon := NewIcon(theme.MenuDropDownIcon())
if s.PlaceHolder == "" {
s.PlaceHolder = defaultPlaceHolder
}
txtProv := NewRichTextWithText(s.Selected)
txtProv.inset = fyne.NewSize(theme.Padding(), theme.Padding())
+ txtProv.Wrapping = fyne.TextTruncate
txtProv.ExtendBaseWidget(txtProv)
if s.disabled {
txtProv.Segments[0].(*TextSegment).Style.ColorName = theme.ColorNameDisabled
}
background := &canvas.Rectangle{}
line := canvas.NewRectangle(theme.ShadowColor())
tapBG := canvas.NewRectangle(color.Transparent)
s.tapAnim = newButtonTapAnimation(tapBG, s)
s.tapAnim.Curve = fyne.AnimationEaseOut
objects := []fyne.CanvasObject{background, line, tapBG, txtProv, icon}
r := &selectRenderer{icon, txtProv, background, line, objects, s}
background.FillColor, line.FillColor = r.bgLineColor()
r.updateIcon()
s.propertyLock.RUnlock() // updateLabel and some text handling isn't quite right, resolve in text refactor for 2.0
r.updateLabel()
return r
} The only issue seems to be that it breaks the select widget tests. The test case widget is small enough (134x36) that it actually truncates the <widget pos="4,4" size="102x28" type="*widget.RichText">
- <text alignment="trailing" pos="4,4" size="94x20">(Select one)</text>
+ <text alignment="trailing" pos="4,4" size="94x20">(Select one</text>
</widget> Not 100% sure what would be the best thing in this instance? |
Thanks @reyemxela You are quite right, adding truncate is the right fix. |
Describe the bug:
Long text in Select boxes overflows out of the box instead of truncating
To Reproduce:
Steps to reproduce the behaviour:
Screenshots:
What it looks like now (v2.1.0):

What it used to do (v2.0.3):

Example code:
Device (please complete the following information):
I did a ton of searching to see if there were any issues already opened about this specific problem, but I didn't see anything.
I'm planning on doing some digging around in fyne to try to see where the problem is coming from, but I'm still learning the internals of the project.
The text was updated successfully, but these errors were encountered: