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

fix(@clack/core): keyboard input not working after await in spinner #182

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

Mist3rBru
Copy link
Contributor

@Mist3rBru Mist3rBru commented Dec 14, 2023

Fix #176

Description

The issue occurred on Windows, when the await line between the spinner start and stop was present, causing the second following prompt to be unresponsive to key inputs (e.g., arrow keys or Ctrl-C), except for the [Enter] key. Additionally, this resulted in the duplication of the first option.

Solution

The solution is identify when it is running on Windows and do not change terminal's mode

if (input.isTTY && !isWindows) input.setRawMode(false);

Tested Environment:

OS: Windows, Ubuntu
Node Version: v18.17.1
Package: @clack/prompts
Package Version: v0.7.0

Snippet to Reproduce

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,
});

Copy link

changeset-bot bot commented Dec 14, 2023

🦋 Changeset detected

Latest commit: a04e418

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clack/core Patch
@clack/prompts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@lucas-zimerman
Copy link

lucas-zimerman commented Dec 14, 2023

that indeed fixes the issues, I just wonder why it only affects the second call

@lucas-zimerman
Copy link

We actually don't need input.setRawMode
The thing is that clear here is being used for two flows (exiting the program if ctrl-c is pressed and clearing the line) instead of one (clearing the line).

On linux, SIGINT should be triggered so we can hook to it (I'll have to check it)

I'll add my suggestions on separated lines so that it can be marked as solved if implemented or discuss specifics parts of the suggestion.

@Lms24
Copy link

Lms24 commented Jan 22, 2024

Hey @natemoo-re friendly bump: any chance this PR could get reviewed and merged in?

Copy link
Collaborator

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix and thanks for your patience!

@rorry121
Copy link

rorry121 commented Jul 2, 2024

Any news?When will a new version be released? @natemoo-re

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

Successfully merging this pull request may close these issues.

[Bug] Keyboard input not working after await in spinner
5 participants