diff options
author | Scott González <scott.gonzalez@gmail.com> | 2017-04-17 12:26:22 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2017-05-02 15:12:04 -0400 |
commit | a3e953b495905d0c67790e65032841451b470ce1 (patch) | |
tree | b36df3e0c88c541faa9a5ec445852e3648d1fd9c /ui/widgets | |
parent | abc9e7ce2f3b60a18bf1f461c7cbfccb3fa02b53 (diff) | |
download | jquery-ui-a3e953b495905d0c67790e65032841451b470ce1.tar.gz jquery-ui-a3e953b495905d0c67790e65032841451b470ce1.zip |
Menu: Don't focus dividers when wrapping via keyboard navigation
Fixes #15157
Closes gh-1804
Diffstat (limited to 'ui/widgets')
-rw-r--r-- | ui/widgets/menu.js | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/ui/widgets/menu.js b/ui/widgets/menu.js index 19d9b90df..b2d976a2b 100644 --- a/ui/widgets/menu.js +++ b/ui/widgets/menu.js @@ -136,7 +136,7 @@ return $.widget( "ui.menu", { // If there's already an active item, keep it active // If not, activate the first item - var item = this.active || this.element.find( this.options.items ).eq( 0 ); + var item = this.active || this._menuItems().first(); if ( !keepActiveItem ) { this.focus( event, item ); @@ -538,11 +538,7 @@ return $.widget( "ui.menu", { }, expand: function( event ) { - var newItem = this.active && - this.active - .children( ".ui-menu " ) - .find( this.options.items ) - .first(); + var newItem = this.active && this._menuItems( this.active.children( ".ui-menu" ) ).first(); if ( newItem && newItem.length ) { this._open( newItem.parent() ); @@ -570,21 +566,27 @@ return $.widget( "ui.menu", { return this.active && !this.active.nextAll( ".ui-menu-item" ).length; }, + _menuItems: function( menu ) { + return ( menu || this.element ) + .find( this.options.items ) + .filter( ".ui-menu-item" ); + }, + _move: function( direction, filter, event ) { var next; if ( this.active ) { if ( direction === "first" || direction === "last" ) { next = this.active [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" ) - .eq( -1 ); + .last(); } else { next = this.active [ direction + "All" ]( ".ui-menu-item" ) - .eq( 0 ); + .first(); } } if ( !next || !next.length || !this.active ) { - next = this.activeMenu.find( this.options.items )[ filter ](); + next = this._menuItems( this.activeMenu )[ filter ](); } this.focus( event, next ); @@ -610,7 +612,7 @@ return $.widget( "ui.menu", { this.focus( event, item ); } else { - this.focus( event, this.activeMenu.find( this.options.items ) + this.focus( event, this._menuItems( this.activeMenu ) [ !this.active ? "first" : "last" ]() ); } }, @@ -634,7 +636,7 @@ return $.widget( "ui.menu", { this.focus( event, item ); } else { - this.focus( event, this.activeMenu.find( this.options.items ).first() ); + this.focus( event, this._menuItems( this.activeMenu ).first() ); } }, |