gitignore.io icon indicating copy to clipboard operation
gitignore.io copied to clipboard

Apply a suggestion on comma key pressed

Open ghost opened this issue 9 years ago • 6 comments

It would be great if UI will apply a suggesstion when comma pressed as like it works now with enter key.

For example, typing "jav,gr,int,win," will select Java, Gradle, IntelliJ and Windows.

I know one can use enter key for that, this just a small additional convenience for users :)

ghost avatar May 11 '16 09:05 ghost

I played with this for a little bit a few days ago; there is no quick parameter that can be set in Select2 that enables this. This can be done, but it requires listening to select2 events and manually triggering the effect.

joeblau avatar May 20 '16 10:05 joeblau

I re-looked into this when I was updating the site. Select 2 has a way to use arbitrary keys to select a tag, but that seems to just act as pressing down and not as pressing enter. I'll keep looking into whether or not this is possible.

joeblau avatar Feb 14 '17 18:02 joeblau

Too lazy to fork... ~~but you can add a new if here~~ to listen for key code 188 (or whatever other keys you want) and select with $(".ignore-search").data('select2').results.trigger('results:select') you will want to preventDefault on that event as well.

EDIT: not in that handler, but that bit of code will trigger selection

Plloi avatar Jan 10 '18 20:01 Plloi

$(".ignore-search").on("select2:open", _=>{
    $(".select2-search__field").keydown(e=>{
        if ($(".ignore-search").data('select2').$results.attr('aria-expanded') === "true" && e.keyCode==188){
          $(".ignore-search").data('select2').results.trigger('results:select');
          e.preventDefault();
        }
    });
});

That should do it.

Plloi avatar Jan 10 '18 21:01 Plloi

J'ai des difficulté avec Github. Je suis encore un novice en ce qui concerne le codage et j'avoue avoir de grande difficulté a mettre en œuvre les conseils de Github ou les tuto sur cette application de codage. Je vais metre du temps a comprendre et a utiliser Github comme il ce dois. Merci a vous et bonne année 2022

Aidateck avatar Jan 11 '22 01:01 Aidateck

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Feb 24 '22 18:02 github-actions[bot]