Skip to content
Permalink
Browse files

Autocompelte: Only run a search if the value has changed; switching f…

…rom a blacklist of keys to ignore. Fixes #5716 - autocomplete triggered when field copied with ctrl-c.
  • Loading branch information...
scottgonzalez committed Jul 20, 2010
1 parent 88ec776 commit 2ed96cb0b8fbeaf8c72fb894242862cef81e84b2
Showing with 4 additions and 14 deletions.
  1. +4 −14 ui/jquery.ui.autocomplete.js
@@ -73,24 +73,14 @@ $.widget( "ui.autocomplete", {
self.element.val( self.term );
self.close( event );
break;
case keyCode.LEFT:
case keyCode.RIGHT:
case keyCode.SHIFT:
case keyCode.CONTROL:
case keyCode.ALT:
case keyCode.COMMAND:
case keyCode.COMMAND_RIGHT:
case keyCode.INSERT:
case keyCode.CAPS_LOCK:
case keyCode.END:
case keyCode.HOME:
// ignore metakeys (shift, ctrl, alt)
break;
default:
// keypress is triggered before the input value is changed
clearTimeout( self.searching );
self.searching = setTimeout(function() {
self.search( null, event );
// only search if the value has changed
if ( self.term != self.element.val() ) {
self.search( null, event );
}
}, self.options.delay );
break;
}

0 comments on commit 2ed96cb

Please sign in to comment.
You can’t perform that action at this time.