Skip to content

[Bug] Keyboard input not working after await in spinner #176

@hfournier

Description

@hfournier

Environment

  • OS: Windows
  • Node Version: v18.17.1
  • Package: @clack/prompts
  • Package Version: v0.7.0]

Describe the bug
After updating to the latest version, prompt behavior has changed after awaiting spinner. The await line between spinner start and stop is causing issues with the second following prompt, where it does not respond to any key input (like arrow keys or even Ctrl-C), only the [Enter] key, which then "activates" the normal behavior, but creates a duplicate of the first option.
With the await line commented out, everything works as expected.
The prompt order does not matter, the second one is always effected.

│
◇  Test anyway?
│  Yes
│
◆  test
│  ◻ A (hint A)
│  ◻ A
│  ◻ B (hint B)
│  ◻ C
└
◇  test
│  B
│
◆  Test anyway?
│  ● Yes / ○ No
│  ○ Yes / ● No

To Reproduce

Steps to reproduce the behavior:

  • Using the following code:
  const sp = p.spinner();
  sp.start("start");
  await setTimeout(2000);
  sp.stop("stop");

  const y = await p.confirm({
    message: "Test anyway?",
  });

  const x = await p.multiselect({
    message: "test",
    options: [
      { value: "a", label: "A", hint: "hint A" },
      { value: "b", label: "B", hint: "hint B" },
      { value: "c", label: "C", hint: "hint C" },
    ],
    required: false,
  });

Expected behavior
To be able to navigate from prompt to prompt using the keyboard, and use Ctrl-C to quit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions