Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show and accept number input too for select input type #363

Open
ucarbehlul opened this issue Apr 30, 2022 · 1 comment
Open

Show and accept number input too for select input type #363

ucarbehlul opened this issue Apr 30, 2022 · 1 comment

Comments

@ucarbehlul
Copy link

ucarbehlul commented Apr 30, 2022

Is your feature request related to a problem?

If you are using the select prompt, it sometimes takes lots of key presses to go to the choice you want, especially if you are going through lots of forms.

Describe the solution you'd like

The select prompt type can show number next to each option and if number is typed and entered it can accept that choice.
If tab is pressed after a number, it can jump to the closest option to that and show the list from that position.
That would improve user experience in long lists.

@ucarbehlul ucarbehlul changed the title Show and accept number for choice input type Show and accept number input too for select input type Apr 30, 2022
@joeykilpatrick
Copy link
Contributor

Seems like a use case for autocomplete. If you have a lot of choices, consider doing something like this:

const colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];
const doubleColors = colors.reduce((doubles, prefix) => {
  colors.forEach((color) => doubles.push(`${prefix}-${color}`));
  return doubles;
}, []);

await prompts({
  type: 'autocomplete',
  name: 'color',
  message: 'Pick your favorite color.',
  choices: doubleColors.map(color => {return {title: color}}),
});

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

No branches or pull requests

2 participants