Skip to content

Commit c48b18b

Browse files
tcrowleyscottgonzalez
authored andcommitted
Menu: Typeahead now accounts for leading whitespace
Fixes #10649 Closes jquerygh-1356
1 parent 29c72fc commit c48b18b

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

tests/unit/menu/menu.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<li class="foo">Salzburg</li>
7676
</ul>
7777
</li>
78-
<li class="foo">Saarland</li>
78+
<li class="foo"> Saarland</li>
7979
<li>Salzburg
8080
<ul>
8181
<li>Delphi

tests/unit/menu/menu_events.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ asyncTest( "handle keyboard navigation and mouse click on menu with dividers and
609609
});
610610

611611
asyncTest( "handle keyboard navigation with spelling of menu items", function() {
612-
expect( 2 );
612+
expect( 3 );
613613
var element = $( "#menu2" ).menu({
614614
focus: function( event ) {
615615
log( $( event.target ).find( ".ui-state-focus" ).index() );
@@ -624,6 +624,8 @@ asyncTest( "handle keyboard navigation with spelling of menu items", function()
624624
equal( logOutput(), "keydown,0,1,3", "Keydown focus Addyston by spelling the first 3 letters" );
625625
element.simulate( "keydown", { keyCode: 68 } );
626626
equal( logOutput(), "keydown,0,1,3,4", "Keydown focus Delphi by repeating the 'd' again" );
627+
element.simulate( "keydown", { keyCode: 83 } );
628+
equal( logOutput(), "keydown,0,1,3,4,5", "Keydown focus Saarland ignoring leading space" );
627629
start();
628630
});
629631
element[ 0 ].focus();

ui/menu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ return $.widget( "ui.menu", {
638638
// Only match on items, not dividers or other content (#10571)
639639
.filter( ".ui-menu-item" )
640640
.filter(function() {
641-
return regex.test( $( this ).text() );
641+
return regex.test( $.trim( $( this ).text() ) );
642642
});
643643
}
644644
});

0 commit comments

Comments
 (0)