aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.selectmenu.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/jquery.ui.selectmenu.js')
-rw-r--r--ui/jquery.ui.selectmenu.js37
1 files changed, 25 insertions, 12 deletions
diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js
index 800503c08..69f863108 100644
--- a/ui/jquery.ui.selectmenu.js
+++ b/ui/jquery.ui.selectmenu.js
@@ -287,17 +287,24 @@ $.widget( "ui.selectmenu", {
},
_move: function( direction, event ) {
+ var filter = ".ui-menu-item",
+ item, next;
+
+ if ( this.isOpen ) {
+ item = this.menuItems.eq( this.focusIndex );
+ } else {
+ item = this.menuItems.eq( this.element[ 0 ].selectedIndex );
+ filter += ":not(.ui-state-disabled)";
+ }
+
if ( direction === "first" || direction === "last" ) {
- // Set focus manually for first or last item
- this.menu.menu( "focus", event, this.menuItems[ direction ]() );
+ next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
} else {
- if ( direction === "previous" && this.menu.menu( "isFirstItem" ) ||
- direction === "next" && this.menu.menu( "isLastItem" ) ) {
- return;
- }
+ next = item[ direction + "All" ]( filter ).eq( 0 );
+ }
- // Move to and focus next or prev item
- this.menu.menu( direction, event );
+ if ( next.length ) {
+ this.menu.menu( "focus", event, next );
}
},
@@ -340,14 +347,14 @@ $.widget( "ui.selectmenu", {
break;
case $.ui.keyCode.ENTER:
if ( this.isOpen ) {
- this.menuInstance.select( event );
+ this._selectMenu( event );
}
break;
case $.ui.keyCode.UP:
if ( event.altKey ) {
this._toggle( event );
} else {
- this._move( "previous", event );
+ this._move( "prev", event );
}
break;
case $.ui.keyCode.DOWN:
@@ -359,13 +366,13 @@ $.widget( "ui.selectmenu", {
break;
case $.ui.keyCode.SPACE:
if ( this.isOpen ) {
- this.menuInstance.select( event );
+ this._selectMenu( event );
} else {
this._toggle( event );
}
break;
case $.ui.keyCode.LEFT:
- this._move( "previous", event );
+ this._move( "prev", event );
break;
case $.ui.keyCode.RIGHT:
this._move( "next", event );
@@ -389,6 +396,12 @@ $.widget( "ui.selectmenu", {
}
},
+ _selectMenu: function( event ) {
+ if ( !this.menuItems.eq( this.focusIndex ).hasClass( "ui-state-disabled" ) ) {
+ this.menuInstance.select( event );
+ }
+ },
+
_select: function( item, event ) {
var oldIndex = this.element[ 0 ].selectedIndex;