piotrmurach / tty-prompt

A beautiful and powerful interactive command line prompt
https://ttytoolkit.org
MIT License
1.47k stars 136 forks source link

Error "active choice ... matches disabled item" if first choice in multi select is disabled and no default provided #96

Closed elad-maimon closed 5 years ago

elad-maimon commented 5 years ago

In the following line there's validation that the active item is not disabled: https://github.com/piotrmurach/tty-prompt/blob/3e36fad642e1e45932ae8cb9a06f8bfadb9364ca/lib/tty/prompt/multi_list.rb#L50

The problem is that it sets the active choice to be the first or the last in the default (aka. pre-selected) list. But if there's no default, and the first is disabled it raises TTY::Prompt::ConfigurationError.

I believe the behavior should be that if no default is provided, the active should be set as the first non-disabled choice.

BTW, great library! Thanks! :)

piotrmurach commented 5 years ago

Hi Elad,

Thanks for using the library!

Agree! Would you mind submitting a patch with a test case?

piotrmurach commented 5 years ago

Fixed and released in v0.18.1.