Inquirer.js icon indicating copy to clipboard operation
Inquirer.js copied to clipboard

List Selected Highlight not changing on arrow key press

Open dsc03 opened this issue 6 years ago • 20 comments

I'm having an issue with running Inquirer in the Mac terminal where when using the 'list' type, the highlighted selection arrow/font style will not move up and down with arrow key presses.

screen shot 2017-09-14 at 3 17 07 pm

In this screenshot, I have pressed the down arrow key twice, and thus the selection choice is actually on 'other', but that selection is not being displayed properly in the UI.

dsc03 avatar Sep 14 '17 22:09 dsc03

Which node version? Did you try updating it?

SBoudrias avatar Sep 15 '17 02:09 SBoudrias

I'm currently on v6.10. I just saw that the recommended version for node is v6.11...not sure if you still think i should try updating.

dsc03 avatar Sep 15 '17 02:09 dsc03

Yes, try updating to the latest node v6.x

SBoudrias avatar Sep 15 '17 02:09 SBoudrias

Experiencing the same issues on v6.11...additionally had a friend try on v8.4 and didn't work.

dsc03 avatar Sep 15 '17 02:09 dsc03

Can you post your code?

SBoudrias avatar Sep 15 '17 03:09 SBoudrias

var inquirer = require('inquirer');
var prompt = inquirer.createPromptModule();
/** VERIFY INITIAL COMMAND PROMPT QUESTION INFO **/
let commandPromptQuestions = {
  type: 'list',
  name: 'command',
  message: 'What operation do you want to perform next?',
  choices: ['this', 'that', 'other', 'next']
};
/** TAKE IN USER INPUTTED COMMAND AND PASS THROUGH SWITCH STATEMENT **/
let commandPrompt = () => {
  prompt(commandPromptQuestions)
    .then(answers => {
      commandRunner(answers.command);
    })

.catch(error => {
  console.log('There was an error with this command! Try again');
  commandPrompt();
})

}```

dsc03 avatar Sep 15 '17 18:09 dsc03

hey! Wanted to see if you had any updates on this issue?? Let me know. Does it seem like I am implementing it correctly given the code above?

dsc03 avatar Sep 19 '17 17:09 dsc03

Looking at the code yes, but it's not a complete example. So there could be other modules touching the TTY that are conflicting with inquirer.

It'll be hard to really help without a full example I can run and reproduce.

SBoudrias avatar Sep 20 '17 02:09 SBoudrias

I was testing it out as a tool so I actually just have a basic server set up with that command you have above (commandRunner was just console logging). I will create a repo for it, push it up and send you the link so you could see everything.

dsc03 avatar Sep 20 '17 02:09 dsc03

https://github.com/dsc03/clitool

dsc03 avatar Sep 20 '17 02:09 dsc03

^^ that was the playground i was testing inquire with and where I was getting issues...the only additional module I'm using in this case is express.

dsc03 avatar Sep 20 '17 02:09 dsc03

hey! Any updates on this?

dsc03 avatar Sep 21 '17 16:09 dsc03

this is because of terminal plugins like i use zsh it doesn't works here, but when i shifted to bash it works fine. we can solve that by adding a script in package.json

 "start":"echo bash && node index.js",

on npm start it will start bash shell and execute the programme. and in bash shell you can use . remember this bash only works in UNIX based systems. not in windows.

saikatharryc avatar Oct 24 '17 09:10 saikatharryc

same issue and I'm on node v10.9.0

nelsonomuto avatar Oct 07 '18 18:10 nelsonomuto

I was having the same issue on Windows 10, Node 11, but I just upgrade to Node 12.2.0 / npm 6.9.0 and the problem went away. Hope this helps someone!

jednano avatar May 18 '19 13:05 jednano

Running nodemon in the npm start script caused this issue for me. I had this: "scripts": { "start": "nodemon --exec babel-node index.js" } Changed it to this. Now my keypresses work as expected: "scripts": { "start": "babel-node index.js" }

knaut avatar Jul 09 '19 19:07 knaut

Running nodemon in the npm start script caused this issue for me. I had this: "scripts": { "start": "nodemon --exec babel-node index.js" } Changed it to this. Now my keypresses work as expected: "scripts": { "start": "babel-node index.js" }

Same issue here, nodemon was the culprit as soon as I changed it to

"scripts": { "start": "node index.js" }

it worked as expected.

AgkTF avatar Jan 18 '20 18:01 AgkTF

@AgkTF @knaut Try the -I option from nodemon:

-I, --no-stdin ........... nodemon passes stdin directly to child process

"scripts": { "start": "nodemon -I --exec babel-node index.js" }

That is working for me.

kuakman avatar Apr 13 '20 21:04 kuakman

Running nodemon in the npm start script caused this issue for me. I had this: "scripts": { "start": "nodemon --exec babel-node index.js" } Changed it to this. Now my keypresses work as expected: "scripts": { "start": "babel-node index.js" }

Same issue here, nodemon was the culprit as soon as I changed it to

"scripts": { "start": "node index.js" }

it worked as expected.

This fixed it for me, too! Nodemon doesn't like it.

sorengrey avatar Mar 12 '21 17:03 sorengrey

@AgkTF @knaut Try the -I option from nodemon:

-I, --no-stdin ........... nodemon passes stdin directly to child process

"scripts": { "start": "nodemon -I --exec babel-node index.js" }

That is working for me.

Awesome.. worked like charm

shiva2021 avatar Apr 04 '21 09:04 shiva2021

Nodemon seems to have been the culprit for me. Once I removed nodemon, it worked!

I had this before: "scripts": { "start": "nodemon --watch 'src/**/*.ts' --exec \"npx ts-node\" index.ts" }

Changed to this and it worked: "scripts": { "start": "ts-node index.ts" }

metellusa avatar Jan 04 '24 20:01 metellusa