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

Select ':key' does not work #151

Open
slowbro opened this issue Sep 29, 2020 · 2 comments · May be fixed by #152
Open

Select ':key' does not work #151

slowbro opened this issue Sep 29, 2020 · 2 comments · May be fixed by #152

Comments

@slowbro
Copy link
Contributor

slowbro commented Sep 29, 2020

Describe the problem

As called out in the docs, one should be able to specify the :key that will select a choice. This doesn't appear to work.

You can specify :key as an additional option which will be used as short name for selecting the choice via keyboard key press.

Steps to reproduce the problem

require 'tty-prompt'

prompt = TTY::Prompt.new
prompt.select( "Make a selection", [
    { name: "Apple", key: "a" },
    { name: "Bacon", key: "b" },
    { name: "Carrot", key: "c" }
])

Actual behaviour

When pressing a, b, or c nothing happens. The selection does not change and nothing is selected.

Expected behaviour

I expected the item to be selected, as if I arrow-key'd down to it and hit 'enter' - or, at the very least, to move the 'cursor' down to that item (though, preferably, the first one)

Describe your environment

  • OS version: Arch 5.8.12-arch1-1-vfio
  • Ruby version: 2.6.5
  • TTY version:
tty (0.10.0)
tty-box (0.4.1)
tty-color (0.5.2)
tty-command (0.9.0)
tty-config (0.3.2)
tty-cursor (0.7.1)
tty-editor (0.5.1)
tty-file (0.8.0)
tty-font (0.4.0)
tty-logger (0.2.0)
tty-markdown (0.6.0)
tty-pager (0.13.0)
tty-pie (0.3.0)
tty-platform (0.3.0)
tty-progressbar (0.17.0)
tty-prompt (0.22.0, 0.21.0)
tty-reader (0.8.0, 0.7.0)
tty-screen (0.8.1, 0.8.0)
tty-spinner (0.9.3)
tty-table (0.11.0)
tty-tree (0.4.0)
tty-which (0.4.2)
@slowbro
Copy link
Contributor Author

slowbro commented Sep 29, 2020

I'm working on a PR for this.

@slowbro slowbro linked a pull request Sep 30, 2020 that will close this issue
@piotrmurach
Copy link
Owner

piotrmurach commented Dec 1, 2020

I must admit that's poorly managed content by me. The choices section was meant more as a generic way to explain how the choices are configured and looking at it now, I can see how it can be misleading. I should've put a caveat to say that only the expand prompt supports the :key parameter. Let's see how this goes, soon all the menu prompts may be in a position to support :key parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants