#419·prompts

Content "scrolls up" when typing a new value after validation fails

Author: 0xmaayanCreated Jun 18, 2024Updated Jun 18, 2024

Describe the bug

When the first prompt validation fails, and then typing a different value, the content "scrolls up" on every keyboard press.

To Reproduce

Consider the code

console.log("Hello");
console.log("\World");

const response = await prompts({
    type: 'number',
    name: 'value',
    message: 'How old are you?',
    validate: value => value < 18 ? `Nightclub is 18+ only` : true
  });

Entering an invalid value, will show up the error message, but then when typing a different value the content scrolls up and goes over the content from console.log

Expected behavior

The prompt stays at the same place and doesnt scroll up

System

  • OS: MacOS 10.14.3
  • Terminal: vscode terminal, Warp
  • Node version: v21.6.2

Additional context

Add any other context about the problem here.