summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/core/dialog.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-09-01 21:22:38 +0200
committerGéry Debongnie <ged@odoo.com>2017-09-04 09:31:59 +0200
commitb7c92ecaac0a76f64f3c304c7c444ed19f3ed2e5 (patch)
treee709c10632b7bec3392608a752b5e4dac57713d4 /addons/web/static/src/js/core/dialog.js
parentc2563dbb0d84f28e76bd5b17e5d842383e3434ca (diff)
[FIX] web: dialog: remove setTimeout making tests fail
... sometimes. When a dialog is destroyed, the last opened dialog (the one which is just below), if any, is focused. This allows to close it directly by pressing ESC. For an unknown reason, this was done in a setTimeout (delay 0). The problem is that the setTimeout made some JS tests fail randomly, when a test ending by closing a dialog was executed right before a test using a many2one inside a dialog. When this happened, the second test failed sometimes because its dialog was focused (because of the previous test) while waiting for the autocomplete dropdown to open, triggering a blur event on the m2o input, and thus making jquery autocomplete aborting the search, and the opening of the dropdown.
Diffstat (limited to 'addons/web/static/src/js/core/dialog.js')
-rw-r--r--addons/web/static/src/js/core/dialog.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/addons/web/static/src/js/core/dialog.js b/addons/web/static/src/js/core/dialog.js
index 6214c99483e..11ce34770de 100644
--- a/addons/web/static/src/js/core/dialog.js
+++ b/addons/web/static/src/js/core/dialog.js
@@ -151,13 +151,12 @@ var Dialog = Widget.extend({
this.$modal.modal('hide');
this.$modal.remove();
- setTimeout(function () { // Keep class modal-open (deleted by bootstrap hide fnct) on body to allow scrolling inside the modal
- var modals = $('body > .modal').filter(':visible');
- if(modals.length) {
- modals.last().focus();
- $('body').addClass('modal-open');
- }
- }, 0);
+ var modals = $('body > .modal').filter(':visible');
+ if (modals.length) {
+ modals.last().focus();
+ // Keep class modal-open (deleted by bootstrap hide fnct) on body to allow scrolling inside the modal
+ $('body').addClass('modal-open');
+ }
}
});