aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/menu
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2017-04-17 12:26:22 -0400
committerScott González <scott.gonzalez@gmail.com>2017-05-02 15:12:04 -0400
commita3e953b495905d0c67790e65032841451b470ce1 (patch)
treeb36df3e0c88c541faa9a5ec445852e3648d1fd9c /tests/unit/menu
parentabc9e7ce2f3b60a18bf1f461c7cbfccb3fa02b53 (diff)
downloadjquery-ui-a3e953b495905d0c67790e65032841451b470ce1.tar.gz
jquery-ui-a3e953b495905d0c67790e65032841451b470ce1.zip
Menu: Don't focus dividers when wrapping via keyboard navigation
Fixes #15157 Closes gh-1804
Diffstat (limited to 'tests/unit/menu')
-rw-r--r--tests/unit/menu/events.js22
-rw-r--r--tests/unit/menu/menu.html10
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/unit/menu/events.js b/tests/unit/menu/events.js
index 90507bddc..fd57373c1 100644
--- a/tests/unit/menu/events.js
+++ b/tests/unit/menu/events.js
@@ -757,4 +757,26 @@ QUnit.test( "#10571: When typing in a menu, only menu-items should be focused",
} );
} );
+QUnit.test( "#15157: Must not focus menu dividers with the keyboard", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 6 );
+
+ var element = $( "#menu-with-dividers" ).menu( {
+ focus: function( event, ui ) {
+ assert.hasClasses( ui.item, "ui-menu-item", "Should have menu item class" );
+ log( ui.item.text() );
+ }
+ } );
+
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
+ setTimeout( function() {
+ assert.equal( logOutput(), "beginning,middle,end,beginning,end", "Should wrap around items" );
+ ready();
+ } );
+} );
+
} );
diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html
index 2d871a4b3..8d70b19df 100644
--- a/tests/unit/menu/menu.html
+++ b/tests/unit/menu/menu.html
@@ -323,6 +323,16 @@
<li class="foo"><div>Addyston</div></li>
<li class="foo"><div>Adelphi</div></li>
</ul>
+
+<ul id="menu-with-dividers">
+ <li>-</li>
+ <li>beginning</li>
+ <li>-</li>
+ <li>middle</li>
+ <li>-</li>
+ <li>end</li>
+ <li>-</li>
+</ul>
</div>
</body>
</html>