[FIX] mass_mailing: solve error on add block mailing
Issue: ====== Adding a new block in mailing in email marketing raises an error. Steps to reproduce the issue: ============================= - Go to email marketing - Create a new mailing - Create one from scratch - Drop any block - `TypeError : Cannor read properties of null (reading 'parentElement')` Origin of the issue: ==================== When we drop the block in the iframe's document we trigger the `click` event but we don't have any selection yet in the document so `anchorNode`will be `null` thus the error. task-3724551 closes odoo/odoo#152814 Signed-off-by: Antoine Guenet (age) <age@odoo.com>
This commit is contained in:
@@ -63,11 +63,13 @@ export const MassMailingSnippetsMenu = snippetsEditor.SnippetsMenu.extend({
|
||||
// To prevent unnecessary tab shifting, we provide a selection for this specific case.
|
||||
if (srcElement.classList.contains('o_mail_wrapper') || srcElement.querySelector('.o_mail_wrapper')) {
|
||||
const selection = this.options.wysiwyg.odooEditor.document.getSelection();
|
||||
const parent = selection.anchorNode.parentElement;
|
||||
if (parent) {
|
||||
srcElement = parent;
|
||||
if (selection.anchorNode) {
|
||||
const parent = selection.anchorNode.parentElement;
|
||||
if (parent) {
|
||||
srcElement = parent;
|
||||
}
|
||||
this._activateSnippet($(srcElement));
|
||||
}
|
||||
this._activateSnippet($(srcElement));
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user