From 09215ef2cda488cafa92c42a8c63e2f1131147d0 Mon Sep 17 00:00:00 2001 From: Richard Worth Date: Tue, 15 Mar 2011 05:39:56 -0400 Subject: [PATCH] Autocomplete: new option autoFocus, default false. Fixed #7032 - Autocomplete: Add option to automatically highlight the first result --- tests/unit/autocomplete/autocomplete_defaults.js | 1 + ui/jquery.ui.autocomplete.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/tests/unit/autocomplete/autocomplete_defaults.js b/tests/unit/autocomplete/autocomplete_defaults.js index fc92f3209..dd5007089 100644 --- a/tests/unit/autocomplete/autocomplete_defaults.js +++ b/tests/unit/autocomplete/autocomplete_defaults.js @@ -4,6 +4,7 @@ var autocomplete_defaults = { appendTo: "body", + autoFocus: false, delay: 300, disabled: false, minLength: 1, diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index c83f042c0..e6acd4b63 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -22,6 +22,7 @@ $.widget( "ui.autocomplete", { defaultElement: "", options: { appendTo: "body", + autoFocus: false, delay: 300, minLength: 1, position: { @@ -362,6 +363,10 @@ $.widget( "ui.autocomplete", { this.menu.blur(); this.menu.refresh(); + if ( this.options.autoFocus ) { + this.menu.next( new $.Event("mouseover") ); + } + // size and position menu ul.show(); this._resizeMenu(); -- 2.39.5