From edfa446fd5f1171aa102ed4176122da571cee113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Geelen=20=28sge=29?= Date: Fri, 28 Oct 2022 07:26:40 +0000 Subject: [PATCH] [FIX] web_editor: block commandbar in non html field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent the PowerBox command bar to open in (non html) Odoo field embedded inside the editable zone. task-3040872 closes odoo/odoo#105372 X-original-commit: cab3a9b9b89a6b1c0d430e5374feb2f963e466fc Signed-off-by: David Monjoie (dmo) Signed-off-by: Geelen Sébastien (sge) --- .../web_editor/static/src/js/wysiwyg/wysiwyg.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 346e24b61a5..f455251c3c6 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -176,8 +176,19 @@ const Wysiwyg = Widget.extend({ getPowerboxElement: () => { 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; + const baseNode = closestElement(selection.anchorNode, 'P, DIV'); + const fieldContainer = closestElement(selection.anchorNode, '[data-oe-field]'); + if (!baseNode || + ( + fieldContainer && + !( + fieldContainer.getAttribute('data-oe-field') === 'arch' || + fieldContainer.getAttribute('data-oe-type') === 'html' + ) + )) { + return false; + } + return baseNode; } }, isHintBlacklisted: node => {