Skip to content
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
22 changes: 22 additions & 0 deletions tests/unit/menu/menu_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,28 @@ asyncTest( "handle keyboard navigation with spelling of menu items", function()
element[ 0 ].focus();
});

asyncTest( "Keep focus on selected item (see #10644)", function() {
expect( 1 );
var element = $( "#menu2" ).menu({
focus: function( event ) {
log( $( event.target ).find( ".ui-state-focus" ).index() );
}
});

log( "keydown", true );
element.one( "menufocus", function() {
element.simulate( "keydown", { keyCode: 65 } );
element.simulate( "keydown", { keyCode: 68 } );
element.simulate( "keydown", { keyCode: 68 } );
element.simulate( "keydown", { keyCode: 89 } );
element.simulate( "keydown", { keyCode: 83 } );
equal( logOutput(), "keydown,0,1,3,3,3",
"Focus stays on 'Addyston', even after other options are eliminated" );
start();
});
element[ 0 ].focus();
});

test( "#9469: Stopping propagation in a select event should not suppress subsequent select events.", function() {
expect( 1 );
var element = $( "#menu1" ).menu({
Expand Down
2 changes: 1 addition & 1 deletion ui/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ return $.widget( "ui.menu", {

if ( match.length ) {
this.focus( event, match );
if ( match.length > 1 ) {
if ( match.length > 0 ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't we typically just write if ( match.length )?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm wondering if this entire if check (and an else) can go away because the same thing is checked two lines earlier.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scottgonzalez Yeah this works fine with this check removed. Good catch. #1355

this.previousFilter = character;
this.filterTimer = this._delay(function() {
delete this.previousFilter;
Expand Down