huh icon indicating copy to clipboard operation
huh copied to clipboard

Shift-tab functionality in general is impossible to use with dynamic forms

Open iloveicedgreentea opened this issue 3 months ago • 1 comments

Describe the bug Consider this code

huh.NewGroup(
	huh.NewMultiSelect[string]().
		Key(keyAccountSelection).
		Options(huh.NewOptions(m.appState.AccountIds...)...).
		Title("Account Selection").
		Validate(validateMultiSelect). // TODO: this blocks shift tab
		Value(&m.appState.SelectedAccountIds),
).WithHideFunc(func() bool { return shouldHideAccountSelection(m) }),

if validateMultiSelect has a check to see if the input is blank, then shift-tab to go back will be blocked. Right now I have to forego input validation.

There are also various issues with shift-tab in general if I am remaking the form and then scrolling with NextGroup like keeping/restoring state. Most of these issues are caused by not being able to access the underlying state of the form, because none of the fields are exported.

To Reproduce use the code above and make a function that returns an error if the input is blank. Then try to shift-tab

Expected behavior Shift-tab would take precedence over input validation or there is a way to access some internal flag to set it to be skippable

iloveicedgreentea avatar Apr 16 '24 16:04 iloveicedgreentea