diff --git a/lib/elements/select.js b/lib/elements/select.js index 6d6727f..d5a7093 100644 --- a/lib/elements/select.js +++ b/lib/elements/select.js @@ -22,7 +22,7 @@ class SelectPrompt extends Prompt { this.msg = opts.message; this.hint = opts.hint || '- Use arrow-keys. Return to submit.'; this.warn = opts.warn || '- This option is disabled'; - this.cursor = opts.initial || 0; + this.cursor = (typeof opts.initial === 'number' && 0 <= opts.initial && opts.initial < this.choices.length) ? opts.initial : 0; this.choices = opts.choices.map((ch, idx) => { if (typeof ch === 'string') ch = {title: ch, value: idx};