fix(choose): selected bug when limit == 1

This commit is contained in:
Maas Lalani 2022-10-07 18:57:26 -04:00
parent 995bd04e38
commit db75c218de
No known key found for this signature in database
GPG key ID: 5A6ED5CBF1A0A000

View file

@ -60,9 +60,13 @@ func (o Options) Run() error {
isSelected := hasSelectedItems && currentSelected < o.Limit && arrayContains(o.Selected, option)
// If the option is selected then increment the current selected count.
if isSelected {
currentSelected++
if o.Limit == 1 {
// When the user can choose only one option don't select the option but
// start with the cursor hovering over it.
startingIndex = i
isSelected = false
} else {
currentSelected++
}
}