fix: render full placeholder text in form inputs

bubbles/v2 textinput truncates the placeholder to its first rune when the
input width is 0 (the default): it sizes the placeholder buffer to
Width()+1 and early-returns after the first character. Set a non-zero
width on every text input (defaultInputWidth) and resize inputs
responsively to the terminal on WindowSizeMsg via FormStep.SetWidth, so
placeholders render in full and inputs fill the available width.

Adds a regression test asserting the placeholder renders past its first
rune.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
jb
2026-06-19 12:28:34 -03:00
co-authored by Claude Opus 4.8
parent 255b4cc299
commit 9943d5f7b7
3 changed files with 50 additions and 1 deletions
+18 -1
View File
@@ -1,6 +1,23 @@
package tui
import "testing"
import (
"strings"
"testing"
)
// Guards against the bubbles bug where a text input with width 0 renders only the
// first rune of its placeholder. NewFormStep must set a non-zero width.
func TestPlaceholderRendersBeyondFirstRune(t *testing.T) {
const placeholder = "postgres://user@host/db"
f := NewFormStep("t", []FormField{
{Id: "url", Label: "URL", Placeholder: placeholder, Type: FieldTypeText},
})
view := f.Fields[0].input.View()
if !strings.Contains(view, "ostgres://user@host/db") {
t.Errorf("placeholder appears truncated; rendered view = %q", view)
}
}
func TestFormStepValues(t *testing.T) {
f := NewFormStep("Test", []FormField{