@@ -100,6 +100,7 @@ $.widget("ui.selectmenu", {
100
100
. bind ( 'click.selectmenu' , function ( ) {
101
101
return false ;
102
102
} )
103
+ // key events for closed menu
103
104
. bind ( "keydown.selectmenu" , function ( event ) {
104
105
var ret = false ;
105
106
switch ( event . keyCode ) {
@@ -208,6 +209,7 @@ $.widget("ui.selectmenu", {
208
209
209
210
// transfer menu click to menu button
210
211
this . list
212
+ // key events for open menu
211
213
. bind ( "keydown.selectmenu" , function ( event ) {
212
214
var ret = false ;
213
215
switch ( event . keyCode ) {
@@ -287,7 +289,7 @@ $.widget("ui.selectmenu", {
287
289
selected : opt . attr ( 'selected' ) ,
288
290
disabled : opt . attr ( 'disabled' ) ,
289
291
classes : opt . attr ( 'class' ) ,
290
- typeahead : opt . attr ( 'typeahead' ) ,
292
+ typeahead : opt . attr ( 'data- typeahead' ) ,
291
293
parentOptGroup : opt . parent ( 'optgroup' ) ,
292
294
bgImage : o . bgImage . call ( opt )
293
295
} ) ;
@@ -317,7 +319,7 @@ $.widget("ui.selectmenu", {
317
319
thisAAttr [ 'aria-disabled' ] = selectOptionData [ i ] . disabled ;
318
320
}
319
321
if ( selectOptionData [ i ] . typeahead ) {
320
- thisAAttr [ 'typeahead' ] = selectOptionData [ i ] . typeahead ;
322
+ thisAAttr [ 'data- typeahead' ] = selectOptionData [ i ] . typeahead ;
321
323
}
322
324
var thisA = $ ( '<a/>' , thisAAttr ) ;
323
325
var thisLi = $ ( '<li/>' , thisLiAttr )
@@ -492,7 +494,6 @@ $.widget("ui.selectmenu", {
492
494
if ( self . _typeAhead_chars . length < 2 ||
493
495
( self . _typeAhead_chars . substr ( - 2 , 1 ) === c && self . _typeAhead_cycling ) ) {
494
496
self . _typeAhead_cycling = true ;
495
-
496
497
// Match only the first character and loop
497
498
matchee = c ;
498
499
}
@@ -514,8 +515,8 @@ $.widget("ui.selectmenu", {
514
515
this . _focusedOptionLi ( ) . data ( 'index' ) ) || 0 ;
515
516
516
517
for ( var i = 0 ; i < this . _optionLis . length ; i ++ ) {
517
- var thisText = this . _optionLis . eq ( i ) . text ( ) . substr ( 0 , matchee . length ) . toLowerCase ( ) ;
518
-
518
+ // use the typeahead text if we have it
519
+ var thisText = ( this . _optionLis . eq ( i ) . find ( "a" ) . attr ( 'data-typeahead' ) || this . _optionLis . eq ( i ) . find ( "a" ) . text ( ) ) . substr ( 0 , matchee . length ) . toLowerCase ( ) ;
519
520
if ( thisText === matchee ) {
520
521
if ( self . _typeAhead_cycling ) {
521
522
if ( nextIndex === null )
@@ -532,11 +533,9 @@ $.widget("ui.selectmenu", {
532
533
}
533
534
534
535
if ( nextIndex !== null ) {
535
- // Why using trigger() instead of a direct method to select the
536
- // index? Because we don't what is the exact action to do, it
537
- // depends if the user is typing on the element or on the popped
538
- // up menu
539
- this . _optionLis . eq ( nextIndex ) . find ( "a" ) . trigger ( eventType ) ;
536
+ // trigger both the li and the a to properly enabling styling?
537
+ // seems like we need to pick one of these things instead
538
+ this . _optionLis . eq ( nextIndex ) . trigger ( eventType ) . find ( "a" ) . trigger ( eventType ) ;
540
539
}
541
540
542
541
self . _typeAhead_timer = window . setTimeout ( function ( ) {
@@ -688,6 +687,7 @@ $.widget("ui.selectmenu", {
688
687
var newIndex = parseInt ( this . _optionLis . filter ( amt ) . data ( 'index' ) , 10 ) ;
689
688
}
690
689
690
+
691
691
if ( newIndex < 0 ) {
692
692
newIndex = 0 ;
693
693
}
@@ -707,7 +707,9 @@ $.widget("ui.selectmenu", {
707
707
( amt > 0 ) ? ++ amt : -- amt ;
708
708
this . _moveFocus ( amt , newIndex ) ;
709
709
} else {
710
- this . _optionLis . eq ( newIndex ) . find ( 'a:eq(0)' ) . attr ( 'id' , activeID ) . focus ( ) ;
710
+ this . _focusedOptionLi ( ) . removeClass ( this . widgetBaseClass + '-item-focus ui-state-hover' ) ;
711
+ this . _optionLis . eq ( newIndex ) . addClass ( this . widgetBaseClass + '-item-focus ui-state-hover' )
712
+ . find ( 'a:eq(0)' ) . attr ( 'id' , activeID ) . focus ( ) ;
711
713
}
712
714
713
715
this . list . attr ( 'aria-activedescendant' , activeID ) ;
@@ -877,4 +879,4 @@ $.widget("ui.selectmenu", {
877
879
}
878
880
} ) ;
879
881
880
- } ) ( jQuery ) ;
882
+ } ) ( jQuery ) ;
0 commit comments