AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.08k stars 351 forks source link

[WIP] Failing test for default not in options in Select prompt #284

Closed antonio-osorio closed 3 years ago

antonio-osorio commented 4 years ago

Hi @AlecAivazis the behavior of the Select prompt when the default value is not one of the options is a bit counter intuitive. I have added a test that shows the failure.

For a select with options "one", "two", default="invalid default" the user sees:

Pick one option:
> one
  two

And if they hit enter, the resulting value is "invalid default"

What would be the preferred behavior? Thoughs:

szechyjs commented 4 years ago

I'm running into this same issue, I would prefer it to select the item at index 0, as that's what simply pressing enter makes it seem like its doing.

AlecAivazis commented 3 years ago

I think this makes sense since it matches the user's actions. Nice recommendation and thanks for the test!

AlecAivazis commented 3 years ago

@antonio-osorio any update?

AlecAivazis commented 3 years ago

Going to close this as its gone a bit stale. if someone wants to pick it up ill gladly review a PR