Bug?: Autocomplete with autoFocus and show options on focus

Bug?: Autocomplete with autoFocus and show options on focus

Hey guys,

I've come across an issue when using autocomplete with autoFocus=true and using:
  1. .click(function (e) {
  2.       $(this).autocomplete("search");
  3. })
to open the list of options.

There's some kind of race condition where the first element in the list is selected for a second and then becomes deselected.

Both features work independently but when combined there is an issue.

Is this a know bug? Is there a fix or workaround?

Here's some code. (I have extended autocomplete for categories, i also tried without category extension with same results):
  1. $.widget("ui.catcomplete", $.ui.autocomplete, {
  2.     _renderMenu: function (ul, items) {
  3.         var self = this,
  4.             currentCategory = "";
  5.         $.each(items, function (index, item) {
  6.             if (item.category !== currentCategory) {
  7.                 ul.append("<li class='ui-autocomplete-category'>" + item.category + "</li>");
  8.                 currentCategory = item.category;
  9.             }
  10.             self._renderItemData(ul, item);
  11.         });
  12.     }
  13. });
  14. var memberSearchTags = [{
  15.     anchor: "ObjectModel.DataStore.Add"
  16.     category: "Methods"
  17.     label: "Add(...)"
  18. }, {
  19.     anchor: "ObjectModel.TextMessage"
  20.     category: "Objects"
  21.     label: "TextMessage"
  22. }];
  23. $("#mysearch")
  24.     .catcomplete({
  25.     source: memberSearchTags,
  26.     select: function (event, ui) {
  27.         $(this).val("");
  28.         return false;
  29.     },
  30.       autoFocus: true,
  31.     minLength: 0
  32. })
  33.     .click(function (e) {
  34.     $(this).catcomplete("search");
  35. });

Thanks much!

Steve