Skip to content

Commit

Permalink
Selectmenu: Simplify selection of focused item via keyboard
Browse files Browse the repository at this point in the history
Don't go through menu to select the currently focused item.

Renamed _selectMenu() to _selectFocusedItem() for clarity.

Closes gh-1224
  • Loading branch information
scottgonzalez committed Apr 18, 2014
1 parent 1272fca commit 62812d9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ui/selectmenu.js
Expand Up @@ -363,7 +363,7 @@ return $.widget( "ui.selectmenu", {
break; break;
case $.ui.keyCode.ENTER: case $.ui.keyCode.ENTER:
if ( this.isOpen ) { if ( this.isOpen ) {
this._selectMenu( event ); this._selectFocusedItem( event );
} }
break; break;
case $.ui.keyCode.UP: case $.ui.keyCode.UP:
Expand All @@ -382,7 +382,7 @@ return $.widget( "ui.selectmenu", {
break; break;
case $.ui.keyCode.SPACE: case $.ui.keyCode.SPACE:
if ( this.isOpen ) { if ( this.isOpen ) {
this._selectMenu( event ); this._selectFocusedItem( event );
} else { } else {
this._toggle( event ); this._toggle( event );
} }
Expand Down Expand Up @@ -412,9 +412,10 @@ return $.widget( "ui.selectmenu", {
} }
}, },


_selectMenu: function( event ) { _selectFocusedItem: function( event ) {
if ( !this.menuItems.eq( this.focusIndex ).hasClass( "ui-state-disabled" ) ) { var item = this.menuItems.eq( this.focusIndex );
this.menuInstance.select( event ); if ( !item.hasClass( "ui-state-disabled" ) ) {
this._select( item.data( "ui-selectmenu-item" ), event );
} }
}, },


Expand Down

0 comments on commit 62812d9

Please sign in to comment.