Skip to content

Comments

Add MultiSelect option to toggle option under cursor when submitting empty prompt#331

Open
sirbrillig wants to merge 3 commits intomikaelmello:mainfrom
sirbrillig:add-select-on-submit-to-multi-select
Open

Add MultiSelect option to toggle option under cursor when submitting empty prompt#331
sirbrillig wants to merge 3 commits intomikaelmello:mainfrom
sirbrillig:add-select-on-submit-to-multi-select

Conversation

@sirbrillig
Copy link

@sirbrillig sirbrillig commented Feb 9, 2026

What?

This PR adds a new option to the MultiSelect prompt called select_on_empty_submit. If set, and no options are selected when the user submits the prompt, the option currently under the cursor will be selected instead of nothing.

This feature gives MultiSelect the ability to act as either Select or MultiSelect, depending on the user's preference. If they only want to pick one option, they don't have to first select it and then submit the prompt; both can be done at the same time.

Note

Naming is hard. If anyone has a better idea for the name of this option, let me know!

Why?

In an app I'm developing, I often ask the user to select from a list of items. Some of those prompts (like "Select an item to edit") only ever work for one item, but others can support multiple items (like "Select items to delete").

For example, in one prompt, whichever items are selected will have a star applied. Most of the time the user will only want to select one of those options, so using a Select makes sense. That way when the user presses Enter, the item under the cursor has a star applied.

But sometimes the user will want to select multiple options, so I'm forced to use MultiSelect. Now, when the user presses Enter, no items are starred. Instead, the user must press Space, and then Enter.

Because the user has two different types of prompts, and both use the same list of options, it's confusing to remember which input pattern they need to use for the situation.

By providing select_on_empty_submit, MultiSelect can support both input patterns. The user can either press Enter immediately to select one item, or they can press Space to check several items before pressing Enter. I feel this more natually simulates UI list patterns where multi-select is optional.

@sirbrillig sirbrillig force-pushed the add-select-on-submit-to-multi-select branch from 30553a1 to e75d1c1 Compare February 9, 2026 00:13
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

Successfully merging this pull request may close these issues.

1 participant