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

Select prompt: Problems & more friendlier initial #24

Closed
tunnckoCore opened this issue Feb 28, 2018 · 2 comments · Fixed by #28
Closed

Select prompt: Problems & more friendlier initial #24

tunnckoCore opened this issue Feb 28, 2018 · 2 comments · Fixed by #28

Comments

@tunnckoCore
Copy link

tunnckoCore commented Feb 28, 2018

One more issue, sorry but.. 😆

I understand that it is normal to be zero based, but is an exposed API, why we should think about it.

Btw, from here we can see one problem. Consider the example

async function run() {
  const response = await prompts({
    type: 'select',
    name: 'type',
    message: 'What is the type of the change?',
    choices: [
      { title: 'Fixing a bug', value: 'fix' },
      { title: 'New feature', value: 'feat' },
      { title: 'Breaking change', value: 'major' },
      { title: 'Non code changes', value: 'chore' },
      { title: 'Documentation changes', value: 'docs' },
    ],
    initial: 3,
  });

  console.log(response);
  // => { type: 'chore' }
}

run()

then click Enter. The response is correct, it selects the fourth (cuz it is zero based, okey). But visually it is not selected when run the program - it stays on the Fix a bug. I'll record asciinema record. So you can see what i'm talking.

https://asciinema.org/a/166247 or

@terkelg
Copy link
Owner

terkelg commented Mar 1, 2018

An exposed API for developers should always be zero based. The end user here is developers working with code that expect a zero based index.

@tunnckoCore
Copy link
Author

tunnckoCore commented Mar 1, 2018

I'm agree on that, what about the another? When initial is set i believe that the arrow in the list should be there (in this case in the fourth item) and not always on the first one. And when the user just enter it should show the title of the selected initial item (in this case Non code changes) and not Fix a bug - it's probably because the arrow is on the first item.

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 a pull request may close this issue.

2 participants