Strict Mode

Strict Mode

strict is enabled by default and it forces the user to pick an item from the list, preventing them from entering their own text.

When you disabled strict, if you type something that eliminates the entire list, then hit Enter, the string from the input will be passed back.

Note: If the list values are Objects and the user inputs a String, you will need to handle either type being returned

// If the list is completely filtered, hitting enter does nothing.
let fruit = await arg(`You can only pick one`, [
`Apple`,
`Banana`,
`Orange`,
])
// If the list is completely filtered, hitting enter sends whatever
// is currently in the input.
let fruitOrInput = await arg(
{
placeholder: `Pick a fruit or type anything`,
strict: false,
},
[`Apple`, `Banana`, `Orange`]
)
await textarea(`${fruit} and ${fruitOrInput}`)
Discuss Post