-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Menubar #829
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
Menubar #829
Conversation
Ensure open sub-menus close on sub-menu-less `click` or `mouseenter` events. See 9f53e0.
Per comment from @scottgonzalez
}); | ||
that._on( input, { | ||
click: function( event ) { | ||
if ( that.open ){ that._close(); } |
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.
This wasn't being checked for that.open
previously, but you're checking now. Is that the correct behavior?
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.
@mikesherov It seems to work the same (mouseenter
is fired before the click) but I can see the wisdom in making the fewest required changes. Will change.
There are three more uses of |
@jzaefferer I've got those |
Okay, so you're still working on this, right? When you push an update, please make sure that you fix your whitespace settings first. It affects all files. |
I went to Hawaii for Thanksgiving. It was beautiful. There were palm There was not any menubar work done. I'll pick it back up this week. Steven On Thu, Nov 22, 2012 at 01:48:42AM -0800, Jörn Zaefferer wrote:
|
@jzaefferer I have removed the other bind calls thanks to @scottgonzalez for help earlier today. Also, this passed the |
}); | ||
} | ||
}); | ||
if ( this.items.length > 0 ) { |
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 is this conditional empty?
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.
@mikesherov Good catch. It's vestigial. Will rm.
@@ -31,7 +31,7 @@ $.widget( "ui.menubar", { | |||
} | |||
}, | |||
_create: function() { | |||
var that = this; | |||
var that = this, subMenus; |
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.
@scottgonzalez @jzaefferer When I look at this _create()
method, it seems there's a lot of initializing sub-tasks going on.
- We're initializing
menuItems
- We're instantiating a
$.ui.menu
s underneath all of thesemenuItems
- We're setting behavior on the
menuItems
and on the sub-menu items - We're defining callbacks that are applied on the sub-menu items....
- etc.
Combine with the jQuery 'dot-chaining' syntax, the method seems to strain easy readability (in my book). This makes the contribution bar higher (IMNSHO) and makes testing / debugging harder. Maybe this isn't so for jQuery gurus such as yourselves, but I think the code would be more approachable if the long methods used intention-revealing sub-methods. I don't see this done elsewhere in the jQuery UI plugin set, but I wanted to get your thoughts on why this is or if this is just my relative unfamiliarity with plugin design.
Questions:
- Is it against jQuery standard to split these
_create()
-homed activities into intention-revealing sub-methods? - Doing so might mean that you have a single
var
declaration in the sub-method and thus chaining becomes less attractive (given the "only onevar
" statement) style rule
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.
It's fine to split up _create()
if the split makes sense. I don't see how the one-var rule has any impact on chaining method calls.
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.
I'll do that in another request, then.
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.
Uninitialized vars at the top, on their own line:
var subMenus,
that = this;
@scottgonzalez Will amend momentarily. |
@scottgonzalez Updated to remove namespacing of the event. |
The `_create()` method had quite a lot going on in it that made it hard to refactor, analyze, or understand. Use sub-functions to encapsulate certain activities.
@jzaefferer, @scottgonzalez Can we merge this? |
.bind( "keydown.menubar", function( event ) { | ||
}); | ||
this._on( subMenus, { | ||
|
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 blank line here
…s item Per @jzaefferer: > Something I didn't write down on the wiki page, > but seems like it should get adressed: When > clicking to open a submenu, hovering the > non-menu-item closes the menu, and another hover > on the closed menu should probably reopen it, > instead of requiring another click. When it gets > closed by a click, it should require the click to > reopen. If that makes sense to you to, we can put > it on the wiki.
@jzaefferer : Addressed point 2 in bb8e2e0 |
I should have finished my coffee before I committed this.
@jzaefferer I think that takes care of your concerns from your last update. I'll await your review. |
Yep, much better. Another minimal round of testing, I hope to have more time for this soonish: The "About" button/link on the second menubar in the demo shouldn't have the dropdown icon, since there is no menu. Otherwise, to keep you busy a bit further, can you take a look at the TODOs at the top here? http://wiki.jqueryui.com/w/page/38666403/Menubar |
@jzaefferer Thanks for the wiki URL, I didn't have that anywhere. |
@jzaefferer aafdc17 should take care of the issue mentioned in the demo. Simple change 🍰 Strangely I didn't know that the |
@sgharms along with the issues described on the wiki, here's a few more, all with the default demo: Tab to the first menubar, then cursor right, down, left.
Tab to the first menubar, then cursor right twice, then shift-tab.
Tab to the second menubar, press cursor left/right.
There's more, but I suspect they are related to those above and should go away when those are fixed. |
@sgharms would be great if you could take another look at the issues from my previous comment. And afterwards we should either just land this PR (yay) or create a new one (okay), since this one has gotten pretty long. |
Looking at last update.... |
@jzaefferer As I read your bullet #2, I'm confused between what it says and what is said about tab/shift-tab in the wiki: Wiki says: Tab/Shift-Tab: Moves focus to the next or previous focusable element. Must be outside the menubar. To move focus within the menubar, use the other keys as described. That seems to imply to me that it should go to something else on the page entirely. In the case of the demo page, it should loop around to the third menubar demo at the bottom. Tab should be able to move between menubars and other inputs but should not be used to move between ui-buttons. Is that right? Assuming your "expected" scenario is the proper behavior to tab to the last menubar of the demo page? |
That's correct, but I don't see that contradicting what I wrote above.
Not entirely sure if that's correct, but it certainly shouldn't move focus within the menubar, as it does right now.
Correct. |
When this is removed it makes the menu item with a submenu eligible for tabbing / shift-tabbing to / from.
@jzaefferer I think this takes care of those three bullets you mentioned. |
Okay, thanks for the update. Though it doesn't look like we're done here. Would be great if you could do more manual keyboard testing as well, as these seem pretty obvious: Tab to first menubar, press cursor right, right, down, left. Should now open the File submenu, instead just closes the Edit submenu. Now press Shift-Tab. Should move focus to something else, instead moves focus to About button inside the menubar. Tab to second menubar. Use cursor left/right. Note that focus doesn't wrap around like it does on the other two menus. Something new I noticed: On touchscreens without hover events, the second menubar is broken. The click event should still open submenus when there's no hover event. I'm fine with ignoring that for this PR and addressing it later though. |
Willfix. On Mon, Mar 18, 2013 at 5:06 AM, Jörn Zaefferer [email protected]:
|
@jzaefferer Fixed the egregious problems from the previous commitset. I still have some funniness around TAB behavior but the menus should be visitable, wrap properly, extend properly, and save extended state properly. |
That looks much better. There's still the issue where shift-tab moves focus to the About item instead of outside the menubar ("funniness around TAB behaviour"?). Should we address that in a new PR? |
I've landed this, squashed into one commit, in 86417ef and merged master in 2253df8 (updating the menubar files to use jQuery 1.9.1). I've made a note of the open issues mentioned here on the wiki page: http://wiki.jqueryui.com/w/page/38666403/Menubar |
Per comments by @scottgonzalez:
bind
to prefer_on