Skip to content

Commit 09215ef

Browse files
committed
Autocomplete: new option autoFocus, default false. Fixed #7032 - Autocomplete: Add option to automatically highlight the first result
1 parent 056cab8 commit 09215ef

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

tests/unit/autocomplete/autocomplete_defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
var autocomplete_defaults = {
66
appendTo: "body",
7+
autoFocus: false,
78
delay: 300,
89
disabled: false,
910
minLength: 1,

ui/jquery.ui.autocomplete.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ $.widget( "ui.autocomplete", {
2222
defaultElement: "<input>",
2323
options: {
2424
appendTo: "body",
25+
autoFocus: false,
2526
delay: 300,
2627
minLength: 1,
2728
position: {
@@ -362,6 +363,10 @@ $.widget( "ui.autocomplete", {
362363
this.menu.blur();
363364
this.menu.refresh();
364365

366+
if ( this.options.autoFocus ) {
367+
this.menu.next( new $.Event("mouseover") );
368+
}
369+
365370
// size and position menu
366371
ul.show();
367372
this._resizeMenu();

0 commit comments

Comments
 (0)