diff options
| author | Julien Mougenot <jum@odoo.com> | 2019-04-17 14:36:17 +0000 |
|---|---|---|
| committer | Julien Mougenot <jum@odoo.com> | 2019-04-30 07:30:56 +0000 |
| commit | ede3317b68a13b5e6b31e489a6f7f05c3292146a (patch) | |
| tree | 507d355aa94ac81629398793cd54943ad4c528ba /addons/web/static/src/js/fields/relational_fields.js | |
| parent | 3f18d67f9eebfa602ed695165759b3ad55cd2b0c (diff) | |
[IMP] web: close dropdowns on scroll
Dropdown from many2xxx and datepicker widgets now close on scroll
to allow access of background information when scrolling.
Related to task #1929483
closes odoo/odoo#32836
Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
Diffstat (limited to 'addons/web/static/src/js/fields/relational_fields.js')
| -rw-r--r-- | addons/web/static/src/js/fields/relational_fields.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index f542cbb771a..751c16b3a23 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -163,6 +163,15 @@ var FieldMany2One = AbstractField.extend({ this.$external_button = this.$('.o_external_button'); return this._super.apply(this, arguments); }, + /** + * @override + */ + destroy: function () { + if (this._onScroll) { + window.removeEventListener('scroll', this._onScroll, true); + } + this._super.apply(this, arguments); + }, //-------------------------------------------------------------------------- // Public @@ -288,12 +297,23 @@ var FieldMany2One = AbstractField.extend({ focus: function (event) { event.preventDefault(); // don't automatically select values on focus }, + open: function (event) { + self._onScroll = function (ev) { + if (ev.target !== self.$input.get(0) && self.$input.hasClass('ui-autocomplete-input')) { + self.$input.autocomplete('close'); + } + }; + window.addEventListener('scroll', self._onScroll, true); + }, close: function (event) { // it is necessary to prevent ESC key from propagating to field // root, to prevent unwanted discard operations. if (event.which === $.ui.keyCode.ESCAPE) { event.stopPropagation(); } + if (self._onScroll) { + window.removeEventListener('scroll', self._onScroll, true); + } }, autoFocus: true, html: true, |
