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:
@@ -33,6 +33,19 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
case tea.WindowSizeMsg:
|
||||
m.width = msg.Width
|
||||
m.height = msg.Height
|
||||
|
||||
// Fit inputs to the terminal: subtract the left padding, the "> " prompt and
|
||||
// the cursor cell, with a sensible floor for very narrow terminals.
|
||||
inputWidth := msg.Width - (padding * 2) - 4
|
||||
if inputWidth < 20 {
|
||||
inputWidth = 20
|
||||
}
|
||||
for _, f := range []*FormStep{
|
||||
&m.loginForm, &m.wireguardForm, &m.appForm,
|
||||
&m.serverForm, &m.dbForm, &m.certForm,
|
||||
} {
|
||||
f.SetWidth(inputWidth)
|
||||
}
|
||||
case spinner.TickMsg:
|
||||
var cmd tea.Cmd
|
||||
m.spinner, cmd = m.spinner.Update(msg)
|
||||
|
||||
Reference in New Issue
Block a user