Input prompt flickers while waiting for validation function
I use the input prompt from the @inquirer/prompts package to handle user input. However, I noticed that the built-in waiting spinner keeps flickering while the validation function is processing. How can I avoid this issue? Thanks.
Terminal: Windows Powershell @inquirer/prompts: 5.0.4 node: v16.20.2
Typescipt Codes to reproduce
import { input } from "@inquirer/prompts";
const validate = async (input: string) => {
await new Promise(resolve => setTimeout(resolve, 5000));
return true
};
(async () => {
let message: string = "select your message"
let defaultValue = "1"
const answer = await input({
message,
default: defaultValue,
validate: validate,
});
console.log(`input value:${answer}`);
})();
https://github.com/SBoudrias/Inquirer.js/assets/162104711/bb6e98c5-07bd-4180-968d-d77051b24769
For reference, here's another fix to a similar issue that was happening in other cases: https://github.com/SBoudrias/Inquirer.js/pull/1379
Pushed a little perf improvement, I'd appreciate if you could test it out and let me know if it's any better for you. I personally don't encounter this flickering in any mac OS prompt - so I'm having a hard time diving deeper into the issue.
hi @SBoudrias Thanks for the response. I checked the latest @inquirer/prompts v5.1.0, the flickers still exist.
This flickering happens when registering the input of the prompts(without validation). I'm thinking to work on this.
@saurabhje that'd be great. Let me know if you get blocked somewhere.
We received a suggestion for a way to improve performance, it's merged and released. Would appreciate feedback form the folks here: does it fix/improve the situation for you?
hi @SBoudrias, I tried @inquirer/prompts:5.3.8, and this issue is resolved on my side. Thank you!
Amazing that's great to hear! Thanks for following up 😁