]> source.dussan.org Git - jquery-ui.git/commitdiff
Selectmenu: Simplify selection of focused item via keyboard
authorScott González <scott.gonzalez@gmail.com>
Tue, 8 Apr 2014 15:20:38 +0000 (11:20 -0400)
committerScott González <scott.gonzalez@gmail.com>
Fri, 18 Apr 2014 16:37:06 +0000 (12:37 -0400)
Don't go through menu to select the currently focused item.

Renamed _selectMenu() to _selectFocusedItem() for clarity.

Closes gh-1224

ui/selectmenu.js

index a612d1982823843c890b709e64487e7ed1cf74d9..7fc2119cb16f192fc33091db3c23d3af07f35b5d 100644 (file)
@@ -363,7 +363,7 @@ return $.widget( "ui.selectmenu", {
                                        break;
                                case $.ui.keyCode.ENTER:
                                        if ( this.isOpen ) {
-                                               this._selectMenu( event );
+                                               this._selectFocusedItem( event );
                                        }
                                        break;
                                case $.ui.keyCode.UP:
@@ -382,7 +382,7 @@ return $.widget( "ui.selectmenu", {
                                        break;
                                case $.ui.keyCode.SPACE:
                                        if ( this.isOpen ) {
-                                               this._selectMenu( event );
+                                               this._selectFocusedItem( event );
                                        } else {
                                                this._toggle( event );
                                        }
@@ -412,9 +412,10 @@ return $.widget( "ui.selectmenu", {
                }
        },
 
-       _selectMenu: function( event ) {
-               if ( !this.menuItems.eq( this.focusIndex ).hasClass( "ui-state-disabled" ) ) {
-                       this.menuInstance.select( event );
+       _selectFocusedItem: function( event ) {
+               var item = this.menuItems.eq( this.focusIndex );
+               if ( !item.hasClass( "ui-state-disabled" ) ) {
+                       this._select( item.data( "ui-selectmenu-item" ), event );
                }
        },