[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) <dmo@odoo.com>
This commit is contained in:
Nicolas Bayet
2021-12-09 12:55:50 +00:00
parent ea5fc6933d
commit 0076f4b491
@@ -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();