Closed lucasoares closed 4 months ago
You're absolutely correct! Thank you so much for this issue!
Hey! @lucasoares What version / commit of huh?
are you on. I can't reproduce with a simple example. Can you share the code that you're using:
github.com/charmbracelet/bubbles v0.18.0
github.com/charmbracelet/bubbletea v0.25.0
github.com/charmbracelet/huh v0.3.0
github.com/charmbracelet/huh/spinner v0.0.0-20240321161533-278656239a9d
github.com/charmbracelet/lipgloss v0.10.0
The first time I execute the form:
Then if I move my selection the help text changes:
Also, if I press tab
in the first option, it confirms the selection, but only enter
should do it.
If I press any key when I'm in the first option, the help text changes too, and tab
key will not confirm anymore. The following example I executed the form, pressed x
and then tried to press tab
Code example:
// Helper functions to create form
func NewForm(groups ...*huh.Group) *huh.Form {
return ConfigureForm(huh.NewForm(groups...))
}
func ConfigureForm(form *huh.Form) *huh,Form {
keymaps := huh.NewDefaultKeyMap()
keymaps.Quit = key.NewBinding(key.WithKeys("ctrl+c", "esc"))
keymaps.Select.SetFilter = key.NewBinding(key.WithKeys("'"), key.WithHelp("'", "set filter"), key.WithDisabled())
keymaps.Select.ClearFilter = key.NewBinding(key.WithKeys("'"), key.WithHelp("'", "clear filter"), key.WithDisabled())
keymaps.MultiSelect.SetFilter = key.NewBinding(key.WithKeys("enter", "'"), key.WithHelp("'", "set filter"), key.WithDisabled())
keymaps.MultiSelect.ClearFilter = key.NewBinding(key.WithKeys("'"), key.WithHelp("'", "clear filter"), key.WithDisabled())
huhForm := form.WithKeyMap(keymaps)
return form: huhForm
}
And using it:
form := NewForm(
huh.NewGroup(
huh.NewSelect[string]().
Title(title).
Description(description).
Options(menuOptions...).
Value(&selected),
),
)
err := form.Run()
This simple example with single item in a single group form will have these issues I mentioned.
Hey, we fixed this on main
! We will do a release soon!
The problem was setting the keymaps and that was fixed in https://github.com/charmbracelet/huh/commit/8c5d66193f2b83a5b6ff2443dec16964d7fe2bb7
Describe the bug The helper
shift+tab back
should be hidden on the first group of a form because there is no group to back to.To Reproduce
Create a form with a single group and execute it.
Screenshots