SBoudrias/Inquirer.js

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

kongku opened this issue · 1 comments

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)

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.