From 73093edc182722ed99b8e4b9f9f2a041d673aeb8 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 20 Oct 2020 16:05:49 +0000 Subject: [PATCH] [FIX] web_editor: stop showing text tools on empty oe_structure Do not switch to text tools if the cursor is in an empty oe_structure (to encourage using snippets there and actually avoid breaking tours which suppose the snippet list is visible). Part of https://github.com/odoo/odoo/pull/64088 Related to task-2352339 This commit has been merged twice as it was lost during JW revert. closes odoo/odoo#64104 X-original-commit: 455f4ec1c5d60d1868f181075ce97a24ee6bc62e Signed-off-by: Quentin Smetz (qsm) --- .../static/src/js/editor/snippets.editor.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 6bfd7fb346c..517f4e62d93 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -2546,8 +2546,16 @@ var SnippetsMenu = Widget.extend({ if (!this._textToolsSwitchingEnabled) { return; } - if (!$.summernote.core.range.create()) { - // Sometimes not enough... + const range = $.summernote.core.range.create(); + if (!range) { + return; + } + if (range.sc === range.ec && range.sc.nodeType === Node.ELEMENT_NODE + && range.sc.classList.contains('oe_structure') + && range.sc.children.length === 0) { + // Do not switch to text tools if the cursor is in an empty + // oe_structure (to encourage using snippets there and actually + // avoid breaking tours which suppose the snippet list is visible). return; } this.textEditorPanelEl.classList.add('d-block');