Permalink
Browse files

Menu: Typeahead now accounts for leading whitespace

Fixes #10649
Closes gh-1356
  • Loading branch information...
tcrowley authored and scottgonzalez committed Oct 7, 2014
1 parent 29c72fc commit c48b18b388b566b4f6a4d833775db70eb62f4f29
Showing with 5 additions and 3 deletions.
  1. +1 −1 tests/unit/menu/menu.html
  2. +3 −1 tests/unit/menu/menu_events.js
  3. +1 −1 ui/menu.js
@@ -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
@@ -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() );
@@ -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();
View
@@ -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() ) );
});
}
});

0 comments on commit c48b18b

Please sign in to comment.