From 0076f4b491e95f4dac88884ee9443a461d4056cc Mon Sep 17 00:00:00 2001 From: Nicolas Bayet Date: Mon, 6 Dec 2021 13:22:54 +0000 Subject: [PATCH] [FIX] web_editor: prevent focus when editor is not loaded It is possible that the wysiwyg focus method is called before the odooEditor being loaded. This commit insure that the odooEditor properly being loaded. Task-2704538 closes odoo/odoo#81114 X-original-commit: 33782020906988322598c4a3e61b8a6b16970aa0 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index ae29fa117f2..2f1a60a02a7 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -776,7 +776,7 @@ const Wysiwyg = Widget.extend({ * Set cursor to the editor latest position before blur or to the last editable node, ready to type. */ focus: function () { - if (!this.odooEditor.historyResetLatestComputedSelection()) { + if (this.odooEditor && !this.odooEditor.historyResetLatestComputedSelection()) { // If the editor don't have an history step to focus to, // We place the cursor after the end of the editor exiting content. const range = document.createRange();