Skip to content

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

Closed
wants to merge 33 commits into from
Closed

Menubar #829

wants to merge 33 commits into from

Conversation

sgharms
Copy link

@sgharms sgharms commented Nov 19, 2012

Per comments by @scottgonzalez:

  • Implement unit test
  • Move away from bind to prefer _on

Steven G. Harms added 2 commits November 18, 2012 19:25
Ensure open sub-menus close on sub-menu-less `click`
or `mouseenter` events.  See 9f53e0.
});
that._on( input, {
click: function( event ) {
if ( that.open ){ that._close(); }
Copy link
Member

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?

Copy link
Author

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.

@jzaefferer
Copy link
Member

There are three more uses of bind which should also get replaced. Also, when you look at the file (not the diff), you can see the whitespace being messed up.

@sgharms
Copy link
Author

sgharms commented Nov 20, 2012

@jzaefferer I've got those bind calls sorted out in another commit. I'll handle them globally when I use @scottgonzalez comments

@jzaefferer
Copy link
Member

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.

@sgharms
Copy link
Author

sgharms commented Nov 28, 2012

I went to Hawaii for Thanksgiving. It was beautiful. There were palm
trees, sandy beaches, beautiful reefs as far as the eye could see.

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:

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.


Reply to this email directly or view it on GitHub:
#829 (comment)

@sgharms
Copy link
Author

sgharms commented Dec 1, 2012

@jzaefferer I have removed the other bind calls thanks to @scottgonzalez for help earlier today. Also, this passed the grunt lint task. My understanding of the jQ UI is imperfect and my JS-fu fairly naïve, so if I've erred let me know.

});
}
});
if ( this.items.length > 0 ) {
Copy link
Member

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?

Copy link
Author

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;
Copy link
Author

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.menus underneath all of these menuItems
  • 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:

  1. Is it against jQuery standard to split these _create()-homed activities into intention-revealing sub-methods?
  2. Doing so might mean that you have a single var declaration in the sub-method and thus chaining becomes less attractive (given the "only one var" statement) style rule

Copy link
Member

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.

Copy link
Author

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.

Copy link
Member

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;

@sgharms
Copy link
Author

sgharms commented Dec 3, 2012

@scottgonzalez Will amend momentarily.

@sgharms
Copy link
Author

sgharms commented Dec 3, 2012

@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.
@sgharms
Copy link
Author

sgharms commented Dec 4, 2012

@jzaefferer, @scottgonzalez Can we merge this?

.bind( "keydown.menubar", function( event ) {
});
this._on( subMenus, {

Copy link
Member

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.
@sgharms
Copy link
Author

sgharms commented Jan 18, 2013

@jzaefferer : Addressed point 2 in bb8e2e0

Steven G. Harms added 2 commits January 18, 2013 09:02
@sgharms
Copy link
Author

sgharms commented Jan 18, 2013

@jzaefferer I think that takes care of your concerns from your last update. I'll await your review.

@jzaefferer
Copy link
Member

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

@sgharms
Copy link
Author

sgharms commented Jan 19, 2013

@jzaefferer Thanks for the wiki URL, I didn't have that anywhere.

@sgharms
Copy link
Author

sgharms commented Jan 20, 2013

@jzaefferer aafdc17 should take care of the issue mentioned in the demo. Simple change 🍰 Strangely I didn't know that the demo directory existed. I'll see what I can knock out from the wiki.

@jzaefferer
Copy link
Member

@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.

  • Expected: Same as pressing escaping, closing the menu and moving focus back to the bar
  • Actual: Menu closes, but there's no focus indicator. Cursor left/right still opens menus, but can't move focus to the non-menu item.

Tab to the first menubar, then cursor right twice, then shift-tab.

  • Expected: Focus moves to previous tabbable.
  • Actual: Focus moves from "Edit" to "File". Looks like bad tab-index handling.

Tab to the second menubar, press cursor left/right.

  • Expected: Moving focus to other items in the second menubar.
  • Actual: Nothing, can't move with cursor keys. Works fine on the other two, so likely related to the menuIcon option.

There's more, but I suspect they are related to those above and should go away when those are fixed.

@jzaefferer
Copy link
Member

@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.

@sgharms
Copy link
Author

sgharms commented Mar 14, 2013

Looking at last update....

@sgharms
Copy link
Author

sgharms commented Mar 15, 2013

@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?

@jzaefferer
Copy link
Member

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's correct, but I don't see that contradicting what I wrote above.

it should loop around to the third menubar demo at the bottom.

Not entirely sure if that's correct, but it certainly shouldn't move focus within the menubar, as it does right now.

Tab should be able to move between menubars and other inputs, but should not be used to move between ui-buttons

Correct.

Steven G. Harms added 4 commits March 16, 2013 11:22
When this is removed it makes the menu item with a
submenu eligible for tabbing / shift-tabbing to /
from.
@sgharms
Copy link
Author

sgharms commented Mar 16, 2013

@jzaefferer I think this takes care of those three bullets you mentioned.

@jzaefferer
Copy link
Member

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.

@sgharms
Copy link
Author

sgharms commented Mar 18, 2013

Willfix.

On Mon, Mar 18, 2013 at 5:06 AM, Jörn Zaefferer [email protected]:

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.


Reply to this email directly or view it on GitHubhttps://github.com//pull/829#issuecomment-15051223
.

@sgharms
Copy link
Author

sgharms commented Mar 22, 2013

@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.

@jzaefferer
Copy link
Member

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?

@jzaefferer
Copy link
Member

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

@jzaefferer jzaefferer closed this Mar 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants