Skip to content

A prompt of type "select" will not run onCancel() when ESC is pressed. #434

@Maxylan

Description

@Maxylan

Describe the bug

Title says it all ~ A prompt of type "select" does not run onCancel() when ESC is pressed.

To Reproduce

Create a prompt w/ a onCancel arrow method, like..

const response = await prompts(
    [
        {
            name: 'pick',
            type: 'select',
            message: 'Pick a choice',
            choices //: [..],
        },
    ],
    {
        onCancel: () => {
            console.log('» Interrupted by user');
            process.exit(1);
        },
    },
);

Run your program, press "ESC" as you encounter the prompt.

Expected behavior

Pressing "ESC" to cancel should invoke the onCancel() method, exiting the process

System

  • OS: wsl Linux, Ubuntu
  • (Linux C-5CG4301X0H 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux)
  • Terminal: bash
  • Node version: v22.15.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions