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

Scale: Initial value for choices cannot be the left-most item #455

Open
gar-r opened this issue Mar 13, 2024 · 1 comment · May be fixed by #456
Open

Scale: Initial value for choices cannot be the left-most item #455

gar-r opened this issue Mar 13, 2024 · 1 comment · May be fixed by #456

Comments

@gar-r
Copy link

gar-r commented Mar 13, 2024

Reproduction

import enquirer from "enquirer";

const { Scale } = enquirer;

const prompt = new Scale({
    message: 'Test Scale',
    scale: [
        { name: "1", message: "Option 1" },
        { name: "2", message: "Option 2" },
        { name: "3", message: "Option 3" },
    ],
    choices: [
        { name: 1, message: "Question 1", initial: 0 },
        { name: 2, message: "Question 2", initial: 0 },
        { name: 3, message: "Question 3", initial: 0 },
    ]
});

await prompt.run();

Expected result

  • left-most choices nodes (Option 1) are selected initially for each question

Actual result

Screenshot 2024-03-13 at 10 58 52
@gar-r gar-r changed the title Scale: Initial value for choices Scale: Initial value for choices cannot be the left-most item Mar 13, 2024
@gar-r
Copy link
Author

gar-r commented Mar 13, 2024

This seems to be caused by this logic in scale.js, which defaults to 2 in case of a falsy initial value.

gar-r added a commit to gar-r/enquirer that referenced this issue Mar 13, 2024
gar-r added a commit to gar-r/enquirer that referenced this issue Mar 13, 2024
@gar-r gar-r linked a pull request Mar 13, 2024 that will close this issue
gar-r added a commit to gar-r/enquirer that referenced this issue Mar 13, 2024
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 a pull request may close this issue.

1 participant