From f1b26335a286a47f685b7830db97c21e6fefd68b Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Thu, 24 Feb 2022 10:45:28 +0000 Subject: [PATCH] [FIX] web: properly bind colorpicker to its owner document In mass_mailing, the colorpicker is in an iframe. There was code to make sure it was bound to its owner document but that code was faulty since it was executed before the colorpicker was appended to the DOM. As a result, all features of the colorpicker that relied on the position of the mouse (eg, selecting a color in an xy selector by dragging a cursor) were broken. This fixes it by using the owner document of the parent class' editable if defined, rather than that of the parent class' element. task-2778415 closes odoo/odoo#85329 X-original-commit: a19d81bcab978150cf01f1ae85543adc5cb92e5e Signed-off-by: David Monjoie (dmo) --- addons/web/static/src/legacy/js/widgets/colorpicker.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/legacy/js/widgets/colorpicker.js b/addons/web/static/src/legacy/js/widgets/colorpicker.js index 5e80566bdbc..41dc2f1ab9a 100644 --- a/addons/web/static/src/legacy/js/widgets/colorpicker.js +++ b/addons/web/static/src/legacy/js/widgets/colorpicker.js @@ -40,7 +40,10 @@ var ColorpickerWidget = Widget.extend({ this.selectedHexValue = ''; // Needs to be bound on document to work in all possible cases. - const $document = $(parent.el && parent.el.ownerDocument || document); + const $document = $( + (parent.el && parent.el.parentElement && parent.el.ownerDocument) + || (parent.options && parent.options.$editable && parent.options.$editable[0] && parent.options.$editable[0].ownerDocument) + || document); $document.on(`mousemove.${this.uniqueId}`, _.throttle((ev) => { this._onMouseMovePicker(ev); this._onMouseMoveSlider(ev);