[FIX] close autocomplete listing on input

Closing previously occured on search request (so that a user wouldn't be able
to select "old" data on new search request), but ``search`` is only triggered
after the search delay. Worked when delay was 0, with it being moved to 250 a
user can get results matching the previous search instead of the current one.

Trigger a closing of the current results list on any ``input`` event, which is
when text is entered in any of the searchview's ``InputView``.

bzr revid: xmo@openerp.com-20140210123416-cfc0x24bfkiv4lse
This commit is contained in:
Xavier Morel
2014-02-10 13:34:16 +01:00
parent 97e0c07430
commit 0821af1af9
+4 -3
View File
@@ -473,12 +473,9 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
* Sets up search view's view-wide auto-completion widget
*/
setup_global_completion: function () {
var self = this;
var autocomplete = this.$el.autocomplete({
source: this.proxy('complete_global_search'),
select: this.proxy('select_completion'),
search: function () { self.$el.autocomplete('close'); },
focus: function (e) { e.preventDefault(); },
html: true,
autoFocus: true,
@@ -486,6 +483,10 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
delay: 250,
}).data('autocomplete');
this.$el.on('input', function () {
this.$el.autocomplete('close');
}.bind(this));
// MonkeyPatch autocomplete instance
_.extend(autocomplete, {
_renderItem: function (ul, item) {