@@ -77,7 +77,7 @@ $.widget( "ui.menu", {
77
77
"mouseleave" : "collapseAll" ,
78
78
"mouseleave .ui-menu" : "collapseAll" ,
79
79
"focus" : function ( event ) {
80
- var firstItem = this . element . children ( ".ui-menu-item" ) . eq ( 0 ) ;
80
+ var firstItem = this . element . children ( ".ui-menu-item" ) . not ( ".ui-state-disabled" ) . eq ( 0 ) ;
81
81
if ( this . _hasScroll ( ) && ! this . active ) {
82
82
var menu = this . element ;
83
83
menu . children ( ) . each ( function ( ) {
@@ -417,7 +417,7 @@ $.widget( "ui.menu", {
417
417
} ,
418
418
419
419
expand : function ( event ) {
420
- var newItem = this . active && this . active . children ( ".ui-menu " ) . children ( ".ui-menu-item" ) . first ( ) ;
420
+ var newItem = this . active && this . active . children ( ".ui-menu " ) . children ( ".ui-menu-item" ) . not ( ".ui-state-disabled" ) . first ( ) ;
421
421
422
422
if ( newItem && newItem . length ) {
423
423
this . _open ( newItem . parent ( ) ) ;
@@ -447,28 +447,27 @@ $.widget( "ui.menu", {
447
447
} ,
448
448
449
449
_move : function ( direction , filter , event ) {
450
- if ( ! this . active ) {
451
- this . focus ( event , this . activeMenu . children ( ".ui-menu-item" ) [ filter ] ( ) ) ;
452
- return ;
453
- }
454
-
455
450
var next ;
456
- if ( direction === "first" || direction === "last" ) {
457
- next = this . active [ direction === "first" ? "prevAll" : "nextAll" ] ( ".ui-menu-item" ) . eq ( - 1 ) ;
458
- } else {
459
- next = this . active [ direction + "All" ] ( ".ui-menu-item" ) . eq ( 0 ) ;
451
+ if ( this . active ) {
452
+ if ( direction === "first" || direction === "last" ) {
453
+ next = this . active [ direction === "first" ? "prevAll" : "nextAll" ] ( ".ui-menu-item" ) . not ( ".ui-state-disabled" ) . eq ( - 1 ) ;
454
+ } else {
455
+ next = this . active [ direction + "All" ] ( ".ui-menu-item" ) . not ( ".ui-state-disabled" ) . eq ( 0 ) ;
456
+ }
457
+ }
458
+ if ( ! next . length || ! this . active ) {
459
+ next = this . activeMenu . children ( ".ui-menu-item" ) [ filter ] ( ) ;
460
460
}
461
461
462
- if ( next . length ) {
463
- this . focus ( event , next ) ;
464
- } else {
465
- this . focus ( event , this . activeMenu . children ( ".ui-menu-item" ) [ filter ] ( ) ) ;
462
+ this . focus ( event , next ) ;
463
+ if ( next . is ( ".ui-state-disabled" ) ) {
464
+ this . _move ( direction , filter , event ) ;
466
465
}
467
466
} ,
468
467
469
468
nextPage : function ( event ) {
470
469
if ( ! this . active ) {
471
- this . focus ( event , this . activeMenu . children ( ".ui-menu-item" ) . first ( ) ) ;
470
+ this . _move ( "next" , "first" , event ) ;
472
471
return ;
473
472
}
474
473
if ( this . isLastItem ( ) ) {
@@ -478,21 +477,21 @@ $.widget( "ui.menu", {
478
477
var base = this . active . offset ( ) . top ,
479
478
height = this . element . height ( ) ,
480
479
result ;
481
- this . active . nextAll ( ".ui-menu-item" ) . each ( function ( ) {
480
+ this . active . nextAll ( ".ui-menu-item" ) . not ( ".ui-state-disabled" ) . each ( function ( ) {
482
481
result = $ ( this ) ;
483
482
return $ ( this ) . offset ( ) . top - base - height < 0 ;
484
483
} ) ;
485
484
486
485
this . focus ( event , result ) ;
487
486
} else {
488
- this . focus ( event , this . activeMenu . children ( ".ui-menu-item" )
487
+ this . focus ( event , this . activeMenu . children ( ".ui-menu-item" ) . not ( ".ui-state-disabled" )
489
488
[ ! this . active ? "first" : "last" ] ( ) ) ;
490
489
}
491
490
} ,
492
491
493
492
previousPage : function ( event ) {
494
493
if ( ! this . active ) {
495
- this . focus ( event , this . activeMenu . children ( ".ui-menu-item" ) . first ( ) ) ;
494
+ this . _move ( "next" , "first" , event ) ;
496
495
return ;
497
496
}
498
497
if ( this . isFirstItem ( ) ) {
@@ -502,14 +501,14 @@ $.widget( "ui.menu", {
502
501
var base = this . active . offset ( ) . top ,
503
502
height = this . element . height ( ) ,
504
503
result ;
505
- this . active . prevAll ( ".ui-menu-item" ) . each ( function ( ) {
504
+ this . active . prevAll ( ".ui-menu-item" ) . not ( ".ui-state-disabled" ) . each ( function ( ) {
506
505
result = $ ( this ) ;
507
506
return $ ( this ) . offset ( ) . top - base + height > 0 ;
508
507
} ) ;
509
508
510
509
this . focus ( event , result ) ;
511
510
} else {
512
- this . focus ( event , this . activeMenu . children ( ".ui-menu-item" ) . first ( ) ) ;
511
+ this . focus ( event , this . activeMenu . children ( ".ui-menu-item" ) . not ( ".ui-state-disabled" ) . first ( ) ) ;
513
512
}
514
513
} ,
515
514
0 commit comments