nrwl / nx

Smart Monorepos ยท Fast CI
https://nx.dev
MIT License
22.71k stars 2.27k forks source link

x-prompt multiselect should select hovered option on enter if no selection is made #22257

Open man-trackunit opened 4 months ago

man-trackunit commented 4 months ago

Description

x-prompt multiselect should select the currently hovered option when pressing enter if no selection is made. Maybe optional.

Motivation

9/10 times when I click through a prompt with multiselect, especially if placed next to simple selects, I end up not selecting anything and have to start over when faced with a multiselect.

Suggested Implementation

Select the currently hovered option on enter if no selection is made.

FrozenPandaz commented 4 months ago

This would make it very difficult to not select anything... Is it perhaps unclear that what you are hovering is not selected? Any suggestions on how we can make it more clear?

man-trackunit commented 4 months ago

Good point with not being able to proceed without making a selection. I guess the first item could be a default none option but I see how that complicates things (although I'd still like it).

I guess having the greyed out checkmark look more like an actual checkbox would be helpful too. ๐Ÿค” CleanShot 2024-03-18 at 08 07 34@2x Artboard

FrozenPandaz commented 2 months ago

What we can do is add a Footer to the prompt, that has the instructions of something along the lines of "Space to select, Enter to confirm". Would you be interested in contributing the change?

AgentEnder commented 2 months ago

If you'd like to contribute the change, you can also change the indicators for the multiselects. Enquirer's typings unfortunately don't allow for the props as needed so you'll have to cast. The selects would look something like this:

const { value } = await prompt</*...*/>({
      type: 'multiselect',
      name: 'value ',
      message: '...',
      choices: [
        // ...
      ],
      footer: 'Press <space> to select, <return> to submit.',
      indicator(state, choice) {
        return choice.enabled ? chalk.green('โ˜‘') : chalk.dim('โ˜');
      },
    } as any);
man-trackunit commented 1 month ago

Alright, thanks for the update. I'll give it a shot on next non-crunch day ๐Ÿ‘Œ