Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OptionsFunc is not ran on first display of group #502

Open
rifelpet opened this issue Dec 30, 2024 · 0 comments
Open

OptionsFunc is not ran on first display of group #502

rifelpet opened this issue Dec 30, 2024 · 0 comments

Comments

@rifelpet
Copy link

Describe the bug
I'm using a Select with OptionsFunc where the inputs to the OptionsFunc depend on values from a previous Group.

After finishing the prior group, the Select displays no values until I press a key like the up/down arrows. At this time the OptionsFunc runs and displays the values.

To Reproduce
Steps to reproduce the behavior:

  1. Apply this patch to the dynamic-country example:
diff --git a/examples/dynamic/dynamic-country/main.go b/examples/dynamic/dynamic-country/main.go
index 76b56f0..84e2c5b 100644
--- a/examples/dynamic/dynamic-country/main.go
+++ b/examples/dynamic/dynamic-country/main.go
@@ -24,6 +24,8 @@ func main() {
                                Value(&country).
                                Title("Country").
                                Height(5),
+               ),
+               huh.NewGroup(
                        huh.NewSelect[string]().
                                Value(&state).
                                Height(8).
  1. Run the example, select a country, and press Enter.
  2. Observe the States selection prompt is blank, no title or options are displayed
  3. Press any key. The title shows up and after the 1s sleep, the country's states are displayed.

Expected behavior
No key press should be required to display the State select and its options.

Screenshots

Here's a screen recording. Note the delay after submitting the country. I waited a few seconds before pressing a key.
https://github.com/user-attachments/assets/1de9e6db-1c25-4cef-8e44-97b4cbc20a7b

Desktop (please complete the following information):

  • OS: macOS
  • Browser: N/A
  • Version: N/A

Additional context
N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant