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

when i accidentally hit enter before propts appeared, propts will receive this enter #1303

Open
kongku opened this issue Sep 12, 2023 · 1 comment

Comments

@kongku
Copy link

kongku commented Sep 12, 2023

when i accidentally hit enter before propts appeared, propts will receive this enter,How to fix this situation?

import { select } from '@inquirer/prompts'

console.log('wait.....')

setTimeout(() => {
  select({
    message: 'select',
    choices: [
      { name: 'a', value: 'a' },
      { name: 'b', value: 'b' },
      { name: 'c', value: 'c' },
    ],
  })
}, 2000)
@SBoudrias
Copy link
Owner

Thanks for the bug report and the code example. I can reproduce it with your snippet easily.

This is a weird behaviour because at the time we press "enter", the readline isn't set, and there's no keypress listener. So it's like there's some kind of replay of the events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants