From e13b4fdb9f5760c90b59cab29d7798956c059f9a Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Thu, 24 Feb 2022 11:15:47 +0000 Subject: [PATCH] [FIX] web_editor: ensure powerbox gets selection from owner document When checking if the powerbox should open, we check the selection but that was done on the global document, which returns a wrong selection for the editable if it's in an iframe. As a result, the powerbox never opened in mass_mailing. task-2778414 closes odoo/odoo#85352 X-original-commit: d5b8c26c46b1daf795a6b286af80bb4dad8072ff Signed-off-by: David Monjoie (dmo) Signed-off-by: Antoine Guenet --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 49bd6179b81..9b3e8c16da0 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -109,7 +109,7 @@ const Wysiwyg = Widget.extend({ getYoutubeVideoElement: getYoutubeVideoElement, getContextFromParentRect: options.getContextFromParentRect, getPowerboxElement: () => { - const selection = document.getSelection(); + const selection = (this.options.document || document).getSelection(); if (selection.isCollapsed && selection.rangeCount) { const node = closestElement(selection.anchorNode, 'P, DIV'); return !(node && node.hasAttribute && node.hasAttribute('data-oe-model')) && node;