displaying suggestions in a textinput overflows the width #961
Replies: 1 comment
-
|
this is a known bug, tracked in #812, still open with no fix. the until it's fixed upstream, the cleanest workaround is to clip the rendered view yourself with lipgloss and place it on a fixed block, rather than truncating the model's internal text (which is what breaks the cursor): func (m model) View() string {
raw := m.textInput.View()
clipped := lipgloss.NewStyle().MaxWidth(m.width).Render(raw)
// wrap in a fixed-width container so neighbors don't shift
return lipgloss.NewStyle().Width(m.width).Render(clipped)
}the key bit is if the suggestion text itself is the eyesore, you can also just not show suggestions ( worth dropping a +1 on #812 if you want it prioritized, the maintainers have acknowledged it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
With the textinput component, the width of the input is ignored when displaying suggestions. In my use case, this is causing the UI to resize in a way that doesn't look very nice. This happens even when the length of the suggestion is shorter than the width of the textinput component.
Is there a way to make the suggestions adhere to the set width of the component? I looked through the documentation and couldn't find anything. I also thought about just truncating the textinput View to the width I was expecting but that caused issues with the cursor. I found another discussion post talking about this issue but no one had responded to it.
Here is the textinput demo code that I was using to test out possible fixes.
Beta Was this translation helpful? Give feedback.
All reactions