From dc17e847785331f2e43968da5444fe55fb61573c Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Mon, 10 Jan 2022 09:46:52 +0000 Subject: [PATCH] [IMP] web_editor: prevent icon and text tools in stars widget When clicking, double clicking or triple clicking in the stars widget of the Powerbox, we don't want to see the regular options of icons or text. This prevents them from showing. task-2575449 closes odoo/odoo#81920 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js | 6 ++++++ addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js index 5e29b49e064..4c7cbc1272c 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js @@ -1827,6 +1827,12 @@ export class OdooEditor extends EventTarget { const sel = this.document.getSelection(); if (!sel.anchorNode) { show = false; + } else { + const selAncestors = [sel.anchorNode, ...ancestors(sel.anchorNode, this.editable)]; + const isInStars = selAncestors.some(node => node.classList && node.classList.contains('o_stars')); + if (isInStars) { + show = false; + } } if (this.options.autohideToolbar) { if (show !== undefined && !this.isMobile) { diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 5ce049f3a6c..927c8a74a11 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -210,7 +210,9 @@ const Wysiwyg = Widget.extend({ }).join(' '); } - self.openMediaDialog(params); + if (!$el.parent().hasClass('o_stars')) { + self.openMediaDialog(params); + } }); if (options.snippets) { @@ -1369,7 +1371,7 @@ const Wysiwyg = Widget.extend({ this.toolbar.$el.find('#create-link').toggleClass('d-none', !range || spansBlocks); // Only show the media tools in the toolbar if the current selected // snippet is a media. - const isInMedia = $target.is(mediaSelector); + const isInMedia = $target.is(mediaSelector) && !$target.parent().hasClass('o_stars'); this.toolbar.$el.find([ '#image-shape', '#image-width',