summaryrefslogtreecommitdiff
path: root/addons/web_editor
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2020-10-20 16:05:49 +0000
committerqsm-odoo <qsm@odoo.com>2020-10-21 12:52:54 +0000
commit2046dc83c8ea983721caf8d019cdc54a459701d4 (patch)
treecf129bcf954143d49c1487301dbef4f09c34fb6c /addons/web_editor
parent922eb35a4db13a06f9edd6dd5cb240b6eb6fa8bf (diff)
[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/60383 Related to task-2352339
Diffstat (limited to 'addons/web_editor')
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.editor.js12
1 files 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 0234c0bc011..c425aea6604 100644
--- a/addons/web_editor/static/src/js/editor/snippets.editor.js
+++ b/addons/web_editor/static/src/js/editor/snippets.editor.js
@@ -2477,8 +2477,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');