Skip to content

Commit 7e1cb95

Browse files
committed
Menu: Open submenu on click of parent item and only close menu when clicking item without submenu.
1 parent b68b116 commit 7e1cb95

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ui/jquery.ui.menu.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ $.widget( "ui.menu", {
7777
mouseHandled = true;
7878

7979
this.select( event );
80-
// Redirect focus to the menu
81-
if ( !this.element.is(":focus") ) {
80+
// Open submenu on click
81+
if ( this.element.has( ".ui-menu" ).length ) {
82+
this.expand( event );
83+
} else if ( !this.element.is(":focus") ) {
84+
// Redirect focus to the menu
8285
this.element.focus();
8386
}
8487
}
@@ -584,7 +587,9 @@ $.widget( "ui.menu", {
584587
// Selecting a menu item removes the active item causing multiple clicks to be missing an item
585588
item: this.active || $( event.target ).closest( ".ui-menu-item" )
586589
};
587-
this.collapseAll( event, true );
590+
if ( !ui.item.has( ".ui-menu" ).length ) {
591+
this.collapseAll( event, true );
592+
}
588593
this._trigger( "select", event, ui );
589594
}
590595
});

0 commit comments

Comments
 (0)