From 0283ce986c6417d9ec151bbb9435f9e35f862c2d Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 20 Oct 2020 16:31:39 +0000 Subject: [PATCH] [FIX] web_editor: prevent switching to text tools immediately On editor start, "the cursor enters editable text" at a "random" time thus switching immediately to text tools or not depending on the fact text tools switching was initialized or not. We now only allow to do so after some fixed delay after the editor is ready, to prevent any automatic switching on editor start (which may break tours). Part of https://github.com/odoo/odoo/pull/64088 task-2352339 This commit has been merged twice as it was lost during JW revert. X-original-commit: 8e0efcd42b6254343aae8faf402e3d8dc630dd14 --- addons/web_editor/static/src/js/editor/snippets.editor.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 ace0bbc8a96..6bfd7fb346c 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -1097,7 +1097,6 @@ var SnippetsMenu = Widget.extend({ const $autoFocusEls = $('.o_we_snippet_autofocus'); this._activateSnippet($autoFocusEls.length ? $autoFocusEls.first() : false); - this._textToolsSwitchingEnabled = true; // Add tooltips on we-title elements whose text overflows this.$el.tooltip({ @@ -1129,6 +1128,12 @@ var SnippetsMenu = Widget.extend({ // animation). (TODO wait for real animation end) setTimeout(() => { this.$window.trigger('resize'); + + // Hacky way to prevent to switch to text tools on editor + // start. Only allow switching after some delay. Switching to + // tools is only useful for out-of-snippet texts anyway, so + // snippet texts can still be enabled immediately. + this._mutex.exec(() => this._textToolsSwitchingEnabled = true); }, 1000); }); },