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

onSelect triggers when clicking the input field

Open BramVanroy opened this issue 7 years ago • 6 comments

It's strange behaviour that when a user selects the input field when a value has been selected already, the onSelect event triggers. In other words:

  1. Type in field
  2. Select suggestion
  3. Click outside field
  4. Click inside field
  5. onSelect is triggered -- even though nothing has changed. The input field merely got focus.

Adding input.off("focus") solves the issue, but I think it should be default behaviour.

BramVanroy avatar Apr 26 '17 09:04 BramVanroy

I can confirm. Workaround worked for us. Thanks

mithri avatar May 10 '17 09:05 mithri

I can't get this solution working. Where i should call this input.off("focus") ? I've tried inside the onSelect callback, but input is not defined. If I try to define it with document.getElementById, it does nothing. Any suggestion?

diegoflag avatar Jul 13 '17 12:07 diegoflag

I think you should use it like this: onSelect: function(suggestion) { $(this).off("focus"); },

php-ini avatar Aug 10 '17 11:08 php-ini

Didn't notice any side-effects for workaround so far. Can anyone think of anything probably going wrong?

fr0z3nfyr avatar Aug 14 '17 09:08 fr0z3nfyr

@diegoflag Look at solution: https://github.com/devbridge/jQuery-Autocomplete/issues/498

roysG avatar Sep 22 '17 16:09 roysG

Set triggerSelectOnValidInput to false on the autocomplete options?

achuinard avatar Feb 06 '18 03:02 achuinard