[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
This commit is contained in:
qsm-odoo
2021-01-05 17:16:18 +00:00
parent 834e3f8f9b
commit 0283ce986c
@@ -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);
});
},