From 5bae0ce6f4299e6ad2c074fba8e4f7e140d6cf18 Mon Sep 17 00:00:00 2001 From: Ravi Gadhia Date: Mon, 20 Jul 2015 14:16:19 +0530 Subject: [PATCH] [FIX] web: autofocus in autocomplete popup on a m2x field * When the autocomplete popup list appears, the focus should be on first element in list, in order to quick create a new record if no match * Tour.js has been modified because jquery ui autocomplete needs a mouseenter event to be notified that this element will be set --- addons/web/static/src/js/tour.js | 1 + addons/web/static/src/js/views/form_relational_widgets.js | 1 + 2 files changed, 2 insertions(+) diff --git a/addons/web/static/src/js/tour.js b/addons/web/static/src/js/tour.js index 5cbb9484191..a3ead5d4dea 100644 --- a/addons/web/static/src/js/tour.js +++ b/addons/web/static/src/js/tour.js @@ -699,6 +699,7 @@ var Tour = { click_event("mouseover"); click_event("mousedown"); click_event("mouseup"); + $element.trigger('mouseenter'); // click_event("mouseenter") doesn't work because jquery event handler register mouseenter as mouseover click_event("click"); if ($element.is("input, textarea, select") && !$element.is(":focus")) { $element.focus(); diff --git a/addons/web/static/src/js/views/form_relational_widgets.js b/addons/web/static/src/js/views/form_relational_widgets.js index ad49dcaf71e..73e68fedf9c 100644 --- a/addons/web/static/src/js/views/form_relational_widgets.js +++ b/addons/web/static/src/js/views/form_relational_widgets.js @@ -290,6 +290,7 @@ var FieldMany2One = common.AbstractField.extend(common.CompletionFieldMixin, com focus: function(e, ui) { e.preventDefault(); }, + autoFocus: true, html: true, // disabled to solve a bug, but may cause others //close: anyoneLoosesFocus,