jQuery-Autocomplete icon indicating copy to clipboard operation
jQuery-Autocomplete copied to clipboard

Suggestion list flipping when triggerSelectOnValidInput is set to false

Open EricAlla opened this issue 11 years ago • 0 comments

Issue: Suggestion list shows up and disappears immediately when using triggerSelectOnValidInput:false. (Please, do not close the issue again without testing it.)

Test scenario for the bug: enter 'a' in the input box and select 'Afghan afghani' from the suggestion list clicking with the mouse. Now, click into the input box and the suggestion list will appear and disappear immediately.

To reproduce the issue, simply use the devbridge package example currently available from gitHub. Then, in demo.js script, simply add "triggerSelectOnValidInput: false,", like below:

// Initialize ajax autocomplete:
$('#autocomplete-ajax').autocomplete({
    triggerSelectOnValidInput: false,
    lookup: countriesArray,
    lookupFilter: function(suggestion, originalQuery, queryLowerCase) {
        var re = new RegExp('\\b' + $.Autocomplete.utils.escapeRegExChars(queryLowerCase), 'gi');
        return re.test(suggestion.value);
    },
    onSelect: function(suggestion) {
        $('#selction-ajax').html('You selected: ' + suggestion.value + ', ' + suggestion.data);
    },
    onHint: function (hint) {
        $('#autocomplete-ajax-x').val(hint);
    },
    onInvalidateSelection: function() {
        $('#selction-ajax').html('You selected: none');
    }
});

EricAlla avatar Feb 02 '15 14:02 EricAlla