From 0821af1af96c0ff59770a32c03b0bd5cdf960c39 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 10 Feb 2014 13:34:16 +0100 Subject: [PATCH] [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 --- addons/web/static/src/js/search.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index fa9bae9969d..903a9f4683e 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -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) {