Skip to content

Allow keydown events to propagate if Dropdown is closed #15065

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

Closed
dunal opened this issue Nov 10, 2014 · 8 comments
Closed

Allow keydown events to propagate if Dropdown is closed #15065

dunal opened this issue Nov 10, 2014 · 8 comments
Labels

Comments

@dunal
Copy link

dunal commented Nov 10, 2014

When element with data-toggle="dropdown" is focused, keydown events could not be cought on parent elements. For example, it's impossible to close containing modal by esc.
It would be better to prevent event propagation only if dropdown is open.

@cvrebert cvrebert added the js label Nov 10, 2014
@hnrch02
Copy link
Collaborator

hnrch02 commented Nov 10, 2014

The modal scenario you described works fine for me: http://jsbin.com/gatuho/1/quiet

@dunal
Copy link
Author

dunal commented Nov 11, 2014

You are right, I have to make description more clear: I can catch an event on parent elements (like modal), but I can not do it on document. Please look at http://jsfiddle.net/t22ev68q/1/ - handler does not work if I press Esc, Up or Down keys.

@twbs-lmvtfy
Copy link

Hi @dunal!

You appear to have posted a live example (http://fiddle.jshell.net/t22ev68q/show/light/), which is always a good first step. However, according to Bootlint, your example has some Bootstrap usage errors, which might potentially be causing your issue:

  • line 59, column 1: E032: .modal-body must be a child of .modal-content

You'll need to fix these errors and post a revised example before we can proceed further.
Thanks!

(Please note that this is a fully automated comment.)

@cvrebert
Copy link
Collaborator

Do you have an example that doesn't involve the third-party bootstrap-select library?

@dunal
Copy link
Author

dunal commented Nov 11, 2014

Yes, here http://jsfiddle.net/t22ev68q/2/ i used a snippet from bootstrap docs, just added tabindex="0" to make element focusable.

@cvrebert
Copy link
Collaborator

cvrebert commented Dec 1, 2014

You need to use an anchor instead of a button to make it focusable in all browsers; see the docs example.

@cvrebert
Copy link
Collaborator

cvrebert commented Mar 6, 2015

Tweaked example: http://jsfiddle.net/ku4vqp2y/7/show/

Well, the Up/Down keys in that case open the menu if it's closed, so that seems like reasonable+intentional behavior. I agree that preventing the propagation of Esc when the menu is closed is kinda weird though.
CC: @hnrch02 @XhmikosR @juthilo for their opinions

@cvrebert cvrebert added the v3 label Aug 19, 2015
@mdo
Copy link
Member

mdo commented Sep 5, 2016

Bootstrap 3 is no longer being officially developed or supported.

All work has moved onto our next major release, v4. As such, this issue or pull request is being closed as a "won't fix." For additional help and support, we recommend utilizing our community resources. Thanks for your understanding, and see you on the other side of v4!

<3,
@mdo and team

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

No branches or pull requests

5 participants