summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/widgets/auto_complete.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2019-01-31 15:38:52 +0000
committerGéry Debongnie <ged@odoo.com>2019-02-04 08:22:34 +0000
commit1f5807f1c8a263cf3d5dd8c2dc02dc8219f486d2 (patch)
treef62f043946ba52d27a7e0dc12917bd3abf8cd600 /addons/web/static/src/js/widgets/auto_complete.js
parentdc4e2b92aabe9f80de0ffba79901530b6a3e149e (diff)
[FIX] web: allow user to move cursor in search bar
With the control panel refactoring, the auto_complete widget was set on a different target, which caused issues with the search bar: the event handlers for the search bar were triggered before the handlers for the auto_complete widget. With this commit, we make sure they are handled in the proper order. Also, a small piece of code that was supposed to check the position of the cursor was lost. closes odoo/odoo#30795
Diffstat (limited to 'addons/web/static/src/js/widgets/auto_complete.js')
-rw-r--r--addons/web/static/src/js/widgets/auto_complete.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/addons/web/static/src/js/widgets/auto_complete.js b/addons/web/static/src/js/widgets/auto_complete.js
index 33405aa4196..6dd78f8f730 100644
--- a/addons/web/static/src/js/widgets/auto_complete.js
+++ b/addons/web/static/src/js/widgets/auto_complete.js
@@ -19,7 +19,7 @@ return Widget.extend({
// to obtain the current search string.
init: function (parent, options) {
this._super(parent);
- this.$input = parent.$el;
+ this.$input = options.$input;
this.source = options.source;
this.select = options.select;
this.get_search_string = options.get_search_string;
@@ -90,14 +90,24 @@ return Widget.extend({
ev.preventDefault();
break;
case $.ui.keyCode.RIGHT:
+ if(self.$input[0].selectionStart < self.search_string.length) {
+ ev.stopPropagation();
+ return;
+ }
self.searching = false;
var current = self.current_result;
if (current && current.expand && !current.expanded) {
self.expand();
self.searching = true;
+ ev.stopPropagation();
}
ev.preventDefault();
break;
+ case $.ui.keyCode.LEFT:
+ if(self.$input[0].selectionStart > 0) {
+ ev.stopPropagation();
+ }
+ break;
case $.ui.keyCode.ESCAPE:
self.close();
self.searching = false;