]> source.dussan.org Git - jquery-ui.git/commitdiff
Menu: Open submenu on click of parent item and only close menu when clicking item...
authorkborchers <kris.borchers@gmail.com>
Tue, 31 Jul 2012 05:00:07 +0000 (00:00 -0500)
committerkborchers <kris.borchers@gmail.com>
Tue, 31 Jul 2012 05:00:07 +0000 (00:00 -0500)
ui/jquery.ui.menu.js

index 75cfac40ba7993692bfc775308cd85744eef861c..055b133198088813cdf933f49009e14093160a28 100644 (file)
@@ -77,8 +77,11 @@ $.widget( "ui.menu", {
                                        mouseHandled = true;
 
                                        this.select( event );
-                                       // Redirect focus to the menu
-                                       if ( !this.element.is(":focus") ) {
+                                       // Open submenu on click
+                                       if ( this.element.has( ".ui-menu" ).length ) {
+                                               this.expand( event );
+                                       } else if ( !this.element.is(":focus") ) {
+                                               // Redirect focus to the menu
                                                this.element.focus();
                                        }
                                }
@@ -584,7 +587,9 @@ $.widget( "ui.menu", {
                        // Selecting a menu item removes the active item causing multiple clicks to be missing an item
                        item: this.active || $( event.target ).closest( ".ui-menu-item" )
                };
-               this.collapseAll( event, true );
+               if ( !ui.item.has( ".ui-menu" ).length ) {
+                       this.collapseAll( event, true );
+               }
                this._trigger( "select", event, ui );
        }
 });