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

fixes TAB and RETURN keys behaviour

Open alpha-and-omega opened this issue 6 years ago • 1 comments

Hi! This patch chages bahaviour when using Tab and Enter to be more consistent with plugin role.

Why: Warning: it is not easy to understand what is wrong, so be ready for some brain work :)

After using this plugin for some time on production website I realised that there is something wrong with it. Fixing it without changing source code went impossible.

Whats wrong:

  • It is impossible to enter short values to the input field USING Tab and Enter keys IF there are longer results in suggestions area AND if mouse pointer is over those results (accidentely it is always there).

This is because active suggestion is changed by mouseover event.

How it should work:

It should be possible to enter any value and finish entering it with Tab or Enter without modification and without generating select action on plugin, wherever mouse pointer is. More strictly - suggestion selection using Tab and Enter should fire only when suggestion was chosen by UP and Down keys, not by mouse.

How to reproduce:

  • Open demo jQuery-Autocomplete/index.htm from the source (can't find it online)
  • Click to the second example (first uses Hint and should work as it is) under "Type NHL or NBA team name:" input field
  • move mouse pointer down a bit, to the "Container" word
  • Try to enter letter "a" and push Tab, this will result to 'Atlanta Thrashers'' selection.
  • As you can see, without moving mouse pointer outside of suggestion area it is impossible to enter "a" symbol to this field
  • Go to google.com and try the same with their suggestion field - google behaves corectly

Patch

Patch provided.

alpha-and-omega avatar Nov 30 '17 20:11 alpha-and-omega

Excellent fix. Much needed.

LorenMaxwell avatar Jan 08 '21 18:01 LorenMaxwell