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

Arrow Keydown event triggers click event for all [role="menu] #16090

Closed
chamelea opened this issue Mar 17, 2015 · 5 comments · Fixed by #16263
Closed

Arrow Keydown event triggers click event for all [role="menu] #16090

chamelea opened this issue Mar 17, 2015 · 5 comments · Fixed by #16263

Comments

@chamelea
Copy link

I am writing my own aria menu object and handling the document click event differently than the document arrow keydown event. I was surprised when dropdown.js actually triggered a click event when I used the down arrow.

See:
https://github.com/twbs/bootstrap/blob/master/js/dropdown.js#L158
https://github.com/twbs/bootstrap/blob/master/js/dropdown.js#L72

@patrickhlauke
Copy link
Member

It fires click in an attempt to keep the code DRY, as opening the menu hangs off the click event [edit: or rather, it hangs off the toggle, which is triggered from click]. So I'd say it's by design. If you're writing a custom object, you may have to override the behavior yourself (which I'm guessing you'd have to do anyway, if implementing your own handler?)

@chamelea
Copy link
Author

Yeah - that's exactly how I'm working around it. I wanted to call it out in case there was a way to better scope to just bootstrap dropdowns. Thanks for the fast reply!

@patrickhlauke
Copy link
Member

oh, now i see what you mean (re scoping to just bootstrap). that's actually an interesting idea (though it would probably require a lot of extra work to do that same kind of scoping explicitly for all components). @fat ?

@cvrebert
Copy link
Collaborator

cvrebert commented Apr 8, 2015

The [role="menu"] event handler was added way back in 9889948#diff-8a0a7067ead1e0530699852517369ddaR149 without much explanation.
Perhaps we could just use .dropdown-menu as the selector instead?

@patrickhlauke
Copy link
Member

i think that would make sense (also in light of parallel discussions in #16179 about possibly removing some of the role="menu" instances to avoid authors tripping AT up unknowingly when they go beyond the normal menu pattern)

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.

3 participants