wuyuntao / jquery-autosuggest

A fork of AutoSuggest jQuery plugin writtern by Drew Wilson.
http://github.com/wuyuntao/jquery-autosuggest
118 stars 59 forks source link

Using tab to select suggestion adds an extra bubble with my leftover text input #6

Closed jmikola closed 13 years ago

jmikola commented 13 years ago

Curious if anyone else can duplicate this. I'm using the plugin for inputting tags. When I enter "th", it fires off an AJAX request and displays a list of choices. If I use the tab key to select a suggested choice, the plugin creates a bubble for "th", followed by my chosen result. If I repeat this and use the enter/return key or a click to make my selection, the "th" (leftovers in my text input) simply gets cleared as it should - no extra bubble.

I can reproduce this in both Firefox and Chrome, so I'm guessing it's a bug. The plugin's config at the time:

$('#us_tags').autoSuggest('/search/searchTags', {
    asHtmlID: 'us_tags',
    minChars: 2,
    neverSubmit: true,
    preFill: getPrefillData(),
    queryParam: 'term',
    searchObjProps: 'label',
    selectedItemProp: 'label',
    selectedValuesProp: 'id',
    selectionAdded: selectionAdded,
    selectionRemoved: selectionRemoved,
    startText: 'Tags',
    usePlaceholder: true
});
wuyuntao commented 13 years ago

I can confirm this bug too.

Fixed in commit https://github.com/wuyuntao/jquery-autosuggest/commit/ab5a7eb1bf8d3a04c15ccc18b37a33a2ccac904b

jmikola commented 13 years ago

Thanks a lot; I was just hoping to get a confirmation before looking into it further, but a patch is even better :)