Opened 12 years ago

Closed 12 years ago

#7579 closed bug (fixed)

autocomplete overwrites input erroneously when user hits ESC before timeout expires

Reported by: efoster Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.autocomplete Version: 1.8.14
Keywords: Cc:
Blocked by: Blocking:

Description

See http://jsbin.com/enulud/4 for an example.

As pointed out by gf3 in #jquery, the problem appears to be at:

https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.autocomplete.js#L113

self.term is being used even if it is not set and/or is outdated.

http://jqueryui.com/demos/autocomplete/remote.html

Also has the problem, but a different version of it:

  1. Enter 'wh'
  2. Wait for the autocomplete list to show up
  3. type 'i', then immediately press Escape
  4. See that the text input has "wh" rather than "whi"

Possible solution: Really, the only time that the text should be replaced is after the user has arrowed down into one of the autocomplete results.

https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.autocomplete.js#L212

could set self._value_orig before it replaces it and the escape handler could replace self._value with self._value_orig if it exists.

Change History (1)

comment:1 Changed 12 years ago by Scott González

Resolution: fixed
Status: newclosed

Autocomplete: Don't react to the escape key if the menu isn't open. Fixes #7579 - autocomplete overwrites input erroneously when user hits ESC before timeout expires.

Changeset: 75415b35eafbd09fbc804d6cfe6d9d6b6b65d17d

Note: See TracTickets for help on using tickets.