-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Dropdowns update - keyboard, touch and submenus #6048
Conversation
This is just a copy of #5067 but rebased against |
…into account .pull-left, .dropup, .dropdown modifier classes). Takes into account whether we entered the menu using up or down. Behaves much like a standard dropdown menu on Mac, minus the submenu showing on focus. As a result of this - .pull-left will cause navigation to the submenu to be the left arrow v right normally. Use opposite direction to go up a level. Use [esc] will bring you back to the initial button focused. Reenables and adds touch support to menus and submenu items. Conflicts: js/bootstrap-dropdown.js
@mdo There are a couple of things I would like to verify with the PR. The first, the click event never actually occurs - it will be intercepted by the touchstart which triggers a click. Is this a way Bootstrap would want to approach something like dropdown menus? It wouldn't match other plugin behaviours so I am hesitant about this. Plus, it won't give the usual 300ms delay for clicks (which may or may not be a good thing). The second is, the touch and focus functionality is almost identical and I would like to combine it into a single function. What is the stance from Bootstrap's code standard point of view - too much magic in a single function if I did this? Thanks |
|
||
if (!/(38|40|27)/.test(e.keyCode)) return | ||
if (!~$.inArray(e.which, [27, 37, 38, 39, 40])) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why change this from regex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason in particular - I think it was because I was looking through the typahead source and matched the functionality there (or perhaps another file). Either should be fine.
E.g. https://github.com/twitter/bootstrap/blob/master/js/bootstrap-typeahead.js#L220
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright, change this back to the regex style, it looks nicer
@mdo Not sure if this fix is going into the If it's not going into Thanks |
Also thinking of changing the click functionality back to being a click instead of touchstart for consistency with the rest of the plugins. |
@@ -26,11 +26,11 @@ | |||
/* DROPDOWN CLASS DEFINITION | |||
* ========================= */ | |||
|
|||
var toggle = '[data-toggle=dropdown]' | |||
var toggle = '[data-toggle="dropdown"]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the double quotes
this is a big patch (nearly doubles the size of the plugin) The more i look at it, the more I think it would be better if I took this on myself. I appreciate you giving it a go though. thanks! |
Fixes:
.dropup
,.dropdown
and.pull-left
modifier classes. E.g. If it's pull-left the left and right arrows switch around, if it's a dropup submenu - we start by focusing the last item vs the first which is at the top.