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

Keyboard control over Bootstrap Dropdown components stops working #2308

Closed
daniel-mf opened this issue Jul 17, 2019 · 7 comments
Closed

Keyboard control over Bootstrap Dropdown components stops working #2308

daniel-mf opened this issue Jul 17, 2019 · 7 comments

Comments

@daniel-mf
Copy link

When I add this plugin, keyboard control of bootstrap dropdown components stops working.
If I remove bootstrap-select.js, they start working again.

  • Bootstrap v4.1.3
  • Bootstrap-select v1.13.10

You can see the example in this test case.

@daniel-mf
Copy link
Author

I've figured out that this plugin intentionally disables keyboard control of bootstrap dropdown by calling $(document).off('keydown.bs.dropdown.data-api')

@daniel-mf
Copy link
Author

I fixed this by adding:

$(document).on(
    'keydown.bs.dropdown.data-api',
    '.dropdown-menu[role="menu"], [data-toggle="dropdown"]:not([role="combobox"])',
    bootstrap.Dropdown._dataApiKeydownHandler
);

Just gotta remember to add role="menu" to my Dropdowns

@caseyjhol caseyjhol reopened this Aug 8, 2019
caseyjhol added a commit that referenced this issue Sep 25, 2019
…lect dropdowns (allow keyboard control over normal Bootstrap dropdown components) (#2308)
@caseyjhol
Copy link
Member

Released in v1.13.12!

@Realex-fire
Copy link

@caseyjhol
Your solution is not entirely correct. keydown.bs.dropdown.data-api will still be attaching to .bootstrap-select .dropdown-menu since the original event is attaching to .dropdown-menu.
You can see this by looking at $._data(document, 'events').
In order for everything to work correctly, the event needs to be re-attach, as suggested by @daniel-mf

@JPBetley
Copy link

JPBetley commented Dec 9, 2019

Seconded what @Realex-fire says here. Observed behavior of using v1.13.12 in our project has shown that the "active" option only changes on first keydown, does not update on subsequent keydown events

@caseyjhol caseyjhol reopened this Apr 16, 2020
caseyjhol added a commit that referenced this issue Apr 16, 2020
…-select selectors. $.off requires the selector matches exactly so the previous method didn't work. (#2308)
@caseyjhol
Copy link
Member

Released in v1.13.13!

@grreeenn
Copy link

grreeenn commented Apr 8, 2024

still facing this in 1.13.18 (BS 3.4.1, jQuery 3.7.1)

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

No branches or pull requests

5 participants