Skip to main content

Search and Top Navigation

#7799 closed bug (fixed)

Opened October 17, 2011 08:14AM UTC

Closed October 17, 2011 12:11PM UTC

Last modified October 17, 2011 01:05PM UTC

Autocomplete regression - Cannot type '&' in IE and Chrome

Reported by: Antoine DESSAIGNE Owned by:
Priority: minor Milestone: git
Component: ui.autocomplete Version: git (not yet released)
Keywords: Cc:
Blocked by: Blocking:
Description

Hi,

I've just found a regression with the 1.9-m6 release: it is impossible to type a '&' in an autocomplete field.

This is due to this commit: https://github.com/jquery/jquery-ui/blob/bdfc6d532c68c092a83461a8b76840719294313f/ui/jquery.ui.autocomplete.js

The problem is that the keyCode on the keydown event is different from the keycode from the keypress event. And thus, it mixed up the 'UP' arrow and the '&'

Here an analysis of the trouble:

|| || Chrome 14 || IE 9 || Firefox 7 ||

|| Can '&' be typed in autocomplete || NO || NO || YES ||

|| '&' keydown code || 49 || 49 || 49 ||

|| '&' keypress code || 38 || 38 || 0 ||

|| 'UP' keydown code || 38 || 38 || 38 ||

|| 'UP' keypress code || No event || No event || 38 ||

|| keydown repeat (1) || YES || YES || YES ||

(1) This indicates whether or not the keydown event is repeated when we keep the keyboard key down.

Since, when holding down a key, the keydown event is triggered multiple times in Firefox 7, I would remove all together the keyCode section handling in the keypress.autocomplete binding method.

Here is a sample demo code: http://pastebin.com/zz54F3Bv. I cannot use either jsFiddle nor jsbin since they don't have the latest version of jQuery UI. The autocomplete field helps seeing whether or not we can type the '&'. The text field displays the events when typing something.

Thanks,

Antoine.

Attachments (0)
Change History (3)

Changed October 17, 2011 12:11PM UTC by Scott González comment:1

resolution: → fixed
status: newclosed

Autocomplete: Avoid handling keypress when keydown modified the search term. Fixes #7799 - Autocomplete regression - Cannot type '&' in IE and Chrome.

Changeset: 63374dcb520f5ad7104ccb57b8eb01dca4087889

Changed October 17, 2011 12:11PM UTC by scottgonzalez comment:2

milestone: 1.9git

Changed October 17, 2011 01:05PM UTC by Antoine DESSAIGNE comment:3

Thanks a lot, it's working perfectly!