Skip to content

Menu: Typeahead not accounting for leading whitespace #1356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/unit/menu/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<li class="foo">Salzburg</li>
</ul>
</li>
<li class="foo">Saarland</li>
<li class="foo"> Saarland</li>
<li>Salzburg
<ul>
<li>Delphi
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/menu/menu_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ asyncTest( "handle keyboard navigation and mouse click on menu with dividers and
});

asyncTest( "handle keyboard navigation with spelling of menu items", function() {
expect( 2 );
expect( 3 );
var element = $( "#menu2" ).menu({
focus: function( event ) {
log( $( event.target ).find( ".ui-state-focus" ).index() );
Expand All @@ -624,6 +624,8 @@ asyncTest( "handle keyboard navigation with spelling of menu items", function()
equal( logOutput(), "keydown,0,1,3", "Keydown focus Addyston by spelling the first 3 letters" );
element.simulate( "keydown", { keyCode: 68 } );
equal( logOutput(), "keydown,0,1,3,4", "Keydown focus Delphi by repeating the 'd' again" );
element.simulate( "keydown", { keyCode: 83 } );
equal( logOutput(), "keydown,0,1,3,4,5", "Keydown focus Saarland ignoring leading space" );
start();
});
element[ 0 ].focus();
Expand Down
2 changes: 1 addition & 1 deletion ui/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ return $.widget( "ui.menu", {
// Only match on items, not dividers or other content (#10571)
.filter( ".ui-menu-item" )
.filter(function() {
return regex.test( $( this ).text() );
return regex.test( $.trim( $( this ).text() ) );
});
}
});
Expand Down