bootstrap-select icon indicating copy to clipboard operation
bootstrap-select copied to clipboard

Close drop down when selecting item with enter key

Open PeterGrand opened this issue 3 years ago • 4 comments

This ensures that the drop down closes after choosing an item by pressing the enter key.

Fixes #2697

PeterGrand avatar Jan 12 '22 17:01 PeterGrand

Hello,

Thank you for proposing a PR to fix an issue.

I cannot reproduce the bug in question: in my hands, pressing enter closes the dropdown. Tried with chromium and firefox on tests/bootstrap5.html. Is the bug reproducible?

NicolasCARPi avatar Jan 12 '22 23:01 NicolasCARPi

I'll see if I can figure out the trick to reproducing. I saw two people mentioning it in discussions and we found it when we updating our django app to Bootstrap 5 with this package.

PeterGrand avatar Jan 15 '22 04:01 PeterGrand

I don't mind merging it as it's a rather small change, but I also know that the smaller the change, the higher risk it has to break other stuff, so that's why I would prefer if it fixes a reproducible issue.

NicolasCARPi avatar Jan 17 '22 11:01 NicolasCARPi

If I may suggest 3 things :

  • I would close the dropdown on Enter or Tab if selectOnTab option is activated
  • I would not call e.preventDefault() to let the focus jump to the next control when you validate your selection
  • It might also seem more readable to insert your code on line 3170, just under this.trigger('focus'), which is called right after the item is actually selected.

Sorry if this is not the right way to comment on somebody else's pull request.

SGunet avatar May 23 '22 13:05 SGunet

Hi, I don't want to unessacarily bump this but I can confirm that this issue is still present in alpha3 (we're currently in the upgrade process to bootstrap 5 as well). I wasn't able to track down any issues on our end why the dropdown menu isn't closing, but maybe I oversaw something...

derklaro avatar Aug 11 '22 08:08 derklaro

@derklaro And does this change fixes the issue you see?

NicolasCARPi avatar Aug 11 '22 12:08 NicolasCARPi

It does! :)

derklaro avatar Aug 11 '22 13:08 derklaro

Looks like this pull request updated the "js/bootstrap-select.js" file but not the "js/bootstrap-select.min.js" file. Just FYI for anyone that might be trying to use this fix, the min and map files were not updated with the changes included in the "js/bootstrap-select.js file.

jp41011 avatar Mar 15 '23 18:03 jp41011