@@ -544,15 +544,15 @@ $(function () {
544
544
$dropdown . trigger ( 'click' )
545
545
} )
546
546
547
- QUnit . test ( 'should skip disabled element when using keyboard navigation' , function ( assert ) {
548
- assert . expect ( 2 )
547
+ QUnit . test ( 'should focus next/previous element when using keyboard navigation' , function ( assert ) {
548
+ assert . expect ( 4 )
549
549
var done = assert . async ( )
550
550
var dropdownHTML = '<div class="tabs">' +
551
551
'<div class="dropdown">' +
552
552
'<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>' +
553
553
'<div class="dropdown-menu">' +
554
- '<a class="dropdown-item disabled " href="#">Disabled link</a>' +
555
- '<a class="dropdown-item" href="#">Another link</a>' +
554
+ '<a id="item1" class="dropdown-item" href="#">A link</a>' +
555
+ '<a id="item2" class="dropdown-item" href="#">Another link</a>' +
556
556
'</div>' +
557
557
'</div>' +
558
558
'</div>'
@@ -568,24 +568,32 @@ $(function () {
568
568
$dropdown . trigger ( $ . Event ( 'keydown' , {
569
569
which : 40
570
570
} ) )
571
- $dropdown . trigger ( $ . Event ( 'keydown' , {
571
+ assert . ok ( $ ( document . activeElement ) . is ( $ ( '#item1' ) ) , 'item1 is focused' )
572
+
573
+ $ ( document . activeElement ) . trigger ( $ . Event ( 'keydown' , {
572
574
which : 40
573
575
} ) )
574
- assert . ok ( ! $ ( document . activeElement ) . is ( '.disabled' ) , '.disabled is not focused' )
576
+ assert . ok ( $ ( document . activeElement ) . is ( $ ( '#item2' ) ) , 'item2 is focused' )
577
+
578
+ $ ( document . activeElement ) . trigger ( $ . Event ( 'keydown' , {
579
+ which : 38
580
+ } ) )
581
+ assert . ok ( $ ( document . activeElement ) . is ( $ ( '#item1' ) ) , 'item1 is focused' )
575
582
done ( )
576
583
} )
577
584
$dropdown . trigger ( 'click' )
578
585
} )
579
586
580
- QUnit . test ( 'should focus next/previous element when using keyboard navigation' , function ( assert ) {
581
- assert . expect ( 4 )
587
+ QUnit . test ( 'should skip disabled element when using keyboard navigation' , function ( assert ) {
588
+ assert . expect ( 3 )
582
589
var done = assert . async ( )
583
590
var dropdownHTML = '<div class="tabs">' +
584
591
'<div class="dropdown">' +
585
592
'<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>' +
586
593
'<div class="dropdown-menu">' +
587
- '<a id="item1" class="dropdown-item" href="#">A link</a>' +
588
- '<a id="item2" class="dropdown-item" href="#">Another link</a>' +
594
+ '<a class="dropdown-item disabled" href="#">Disabled link</a>' +
595
+ '<button class="dropdown-item" type="button" disabled>Disabled button</button>' +
596
+ '<a id="item1" class="dropdown-item" href="#">Another link</a>' +
589
597
'</div>' +
590
598
'</div>' +
591
599
'</div>'
@@ -601,17 +609,11 @@ $(function () {
601
609
$dropdown . trigger ( $ . Event ( 'keydown' , {
602
610
which : 40
603
611
} ) )
604
- assert . ok ( $ ( document . activeElement ) . is ( $ ( '#item1' ) ) , 'item1 is focused' )
605
-
606
- $ ( document . activeElement ) . trigger ( $ . Event ( 'keydown' , {
612
+ assert . ok ( $ ( document . activeElement ) . is ( $ ( '#item1' ) ) , '#item1 is focused' )
613
+ $dropdown . trigger ( $ . Event ( 'keydown' , {
607
614
which : 40
608
615
} ) )
609
- assert . ok ( $ ( document . activeElement ) . is ( $ ( '#item2' ) ) , 'item2 is focused' )
610
-
611
- $ ( document . activeElement ) . trigger ( $ . Event ( 'keydown' , {
612
- which : 38
613
- } ) )
614
- assert . ok ( $ ( document . activeElement ) . is ( $ ( '#item1' ) ) , 'item1 is focused' )
616
+ assert . ok ( $ ( document . activeElement ) . is ( $ ( '#item1' ) ) , '#item1 is still focused' )
615
617
done ( )
616
618
} )
617
619
$dropdown . trigger ( 'click' )
0 commit comments