From 8f2a03077b04d24cab3500cabca422931b7de714 Mon Sep 17 00:00:00 2001 From: "Mahdi Cheikh Rouhou (macr)" Date: Fri, 29 Mar 2024 09:29:26 +0100 Subject: [PATCH] [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) Signed-off-by: Mahdi Cheikh Rouhou (macr) --- addons/web/static/src/core/colorpicker/colorpicker.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/web/static/src/core/colorpicker/colorpicker.js b/addons/web/static/src/core/colorpicker/colorpicker.js index a6bb93647d2..b9f3177a2d0 100644 --- a/addons/web/static/src/core/colorpicker/colorpicker.js +++ b/addons/web/static/src/core/colorpicker/colorpicker.js @@ -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); }