[FIX] web_editor: colorPalette mount in mass_mailing
Since [1], the colorPalette component is mounted on a new App via the attachComponent compatibility util. The new App is subject to target validation, which fails in mass_mailing and raises a traceback. This happens because the element for mounting the color palette is created by the top window's document and later attached to the iframe's DOM tree. Unfortunately this holds true for the entire sidebar is mass_mailing. Commit [2] apparently added some flexibility to the attachComponent util, temporarily disabling target validation when about to mount an App. But, due to the asynchronous nature of mounting an App, this was not enough for the present case, as the original App.validateTarget function is restored before it gets called when mounting the ColorPalette. This commit fixes this localized issued, leaving a large-scale fix, in which the snippets menu elements are properly created by the correct document, for a future commit on master. This will have to take into consideration the fact that the code for the snippets menu is shared between mass_mailing and website, and that, in the latter, the snippets menu sits outside the iframe, thus, it is part of the top document tree. Alternatively, the snippets menu should be refactored and converted to owl. task-3605859 [1]: https://github.com/odoo/odoo/commit/36061a4ab017a463c1d5bf838334cb4c0fac25ee [2]: https://github.com/odoo/odoo/commit/6a30ab13536a2dc0a8f23df32962cd1ceec71a5d closes odoo/odoo#143340 Signed-off-by: Antoine Guenet (age) <age@odoo.com> Co-authored-by: Jinjiu Liu <jili@odoo.com>
This commit is contained in:
co-authored by
Jinjiu Liu
parent
fc1d293e70
commit
b8fe3ee779
@@ -1778,6 +1778,16 @@ const ColorpickerUserValueWidget = SelectUserValueWidget.extend({
|
||||
options.getTemplate = wysiwyg.getColorpickerTemplate.bind(wysiwyg);
|
||||
}
|
||||
this.colorPaletteWrapper?.destroy();
|
||||
const sidebarDocument = this.colorPaletteEl.ownerDocument;
|
||||
if (!(this.colorPaletteEl instanceof sidebarDocument.defaultView.HTMLElement)) {
|
||||
// When inside an iframe, the element for mounting a component must
|
||||
// be an instance of the iframe's HTMLElement, or else target
|
||||
// validation for attachComponent fails.
|
||||
const newEl = sidebarDocument.importNode(this.colorPaletteEl, true);
|
||||
this.colorPaletteEl.before(newEl);
|
||||
this.colorPaletteEl.remove();
|
||||
this.colorPaletteEl = newEl;
|
||||
}
|
||||
this.colorPaletteWrapper = await attachComponent(this, this.colorPaletteEl, ColorPalette, options);
|
||||
},
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user