Autocomplete menu issue

Autocomplete menu issue

I'm noticing a weird issue when using autocomplete with a remote datasource that takes a bit of time to return.
(Noticed in jQuery UI 1.8.9)

If you've typed some text, and then move your mouse around on the menu while waiting for the source to return some data, the input value is reverted back to what it was before the last data request.

For example, with a datasource that takes a couple seconds to return:
-type some text, and wait a couple seconds
-a menu appears with some options
-type some more text
-before the menu is updated, move your mouse around over it
-the text you just typed disappears

I've reduced this down to the following very simple script that illustrates the above point by using setTimeout to fake an ajax delay.
  1. <script>
  2. $(function() {
  3.         function fakeData(request, response) {
  4.             setTimeout(function(){
  5.                 response(['Item A', 'Item B', 'Item C']);
  6.             }, 2000);
  7.         }
  8.         $( "#tags" ).autocomplete({source: fakeData});
  9. });
  10. </script>
  11. <input id="tags" />

For my own purposes, I've hacked a fix that seems to work by removing the autocomplete menu's blur() callback.
  1. $('#tags').data('autocomplete').menu.options.blur = function() {};
...but I'm sure there must have been a reason for this function in the first place... so I'm not sure what side effects I've introduced by removing it.
    • Topic Participants

    • jdc