From 3422b96a7378823bd4bbb823d551ac7e102d5c43 Mon Sep 17 00:00:00 2001 From: jpr-odoo Date: Mon, 7 Oct 2019 06:44:14 +0000 Subject: [PATCH] [FIX] web_editor: fixed the traceback on close modal dialog The issue here is, for modal dialogs (eg newsletter popup), when we close the dialog, the modal is destroyed and so after the delayed execution due to timeout, the dialog will not be available and it will generate the issue. removed delayed execution for the traceback, which is relevant to the modal dialogs. task-2075232 closes odoo/odoo#38914 X-original-commit: 93deb25f873f5c4aba239b050e543b23685f5ba0 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/editor/rte.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js index 529bf68887e..5c3fad24f64 100644 --- a/addons/web_editor/static/src/js/editor/rte.js +++ b/addons/web_editor/static/src/js/editor/rte.js @@ -674,13 +674,19 @@ var RTEWidget = Widget.extend({ if (this && this.$last && (!$editable.length || this.$last[0] !== $editable[0])) { var $destroy = this.$last; history.splitNext(); - - _.delay(function () { + // In some special cases, we need to clear the timeout. + var lastTimerId = _.delay(function () { var id = $destroy.data('note-id'); $destroy.destroy().removeData('note-id').removeAttr('data-note-id'); $('#note-popover-'+id+', #note-handle-'+id+', #note-dialog-'+id+'').remove(); }, 150); // setTimeout to remove flickering when change to editable zone (re-create an editor) this.$last = null; + // for modal dialogs (eg newsletter popup), when we close the dialog, the modal is + // destroyed immediately and so after the delayed execution due to timeout, dialog will + // not be available, leading to trace-back, so we need to clearTimeout for the dialogs. + if ($destroy.hasClass('modal-body')) { + clearTimeout(lastTimerId); + } } if ($editable.length && (!this.$last || this.$last[0] !== $editable[0])) { $editable.summernote(this._getConfig($editable));