Inquirer.js
Inquirer.js copied to clipboard
rawList - default doesn't work anymore
I was previously using inquirer version 7.3.3 and have decided to upgrade to the latest. Everything seems to work great except rawList's default selection seems broken now. In v7 default was the actual value you wanted as a default. In v12, default is an index, however, this feature doesn't work for me at all. I've put together a minimal repro:
import inquirer from 'inquirer';
async function testRawListDefault() {
const answer = await inquirer.prompt([
{
type: 'rawlist',
name: 'choice',
message: 'Select an option (default should be "Option 3"):',
choices: [
'Option 1',
'Option 2',
'Option 3',
'Option 4',
'Option 5',
'Option 6',
],
default: 2
}
]);
console.log('\nYou selected:', answer.choice);
}
testRawListDefault().catch(console.error);
This does not work for me on v12.11.1 (latest at the time of writing):
It doesn't pre-select any option (despite passing a default of 2)