[FIX] web: fix gradient colorpicker traceback

Issue:
======
traceback when clicking on gradient colorpicker in mass_mailing

Steps to reproduce the issue:
=============================
- Got to email marketing
- Add some text
- Select the text and go to graadient and activate custom
- click any color in the colorpalette -> traceback

Origin of the issue:
====================
Some colorpickers are created inside the snippets sidebar and then gets
removed by `_updateRightPanelContent` in `SnippetsMenu` so the owl
components corrosponding to them will have `this.el = null` which will
cause a problem when updating the props since we will use it in the
update.

task-3834112

closes odoo/odoo#161275

X-original-commit: 9ccd820813f6c0bd7608e80570a6999577aff513
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Mahdi Cheikh Rouhou (macr) <macr@odoo.com>
This commit is contained in:
Mahdi Cheikh Rouhou (macr)
2024-04-12 08:16:10 +00:00
parent 143cbeeba7
commit 8f2a03077b
@@ -85,6 +85,14 @@ export class Colorpicker extends Component {
this.start();
});
onWillUpdateProps((newProps) => {
if (!this.el) {
// There is legacy code that can trigger the instantiation of the
// link tool when one of it's parent component is not in the dom. If
// that parent element is not in the dom, owl will not return
// `this.linkComponentWrapperRef.el` because of a check (see
// `inOwnerDocument`).
return;
}
if (newProps.selectedColor) {
this.setSelectedColor(newProps.selectedColor);
}