From 8eb0ca54200f0f8e1078bb6a0d507e747ccea122 Mon Sep 17 00:00:00 2001 From: "Arthur Detroux (ard)" Date: Tue, 24 May 2022 12:54:28 +0200 Subject: [PATCH] [FIX] web_editor: clear tooltips before quitting editor See merge commit for more information. task-2687506 --- .../web_editor/static/src/js/wysiwyg/wysiwyg.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 8581e8d6aa9..5ff21794111 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -94,6 +94,7 @@ const Wysiwyg = Widget.extend({ // more heuristics to bypass the limitation. this._isOnline = true; this._signalOnline = this._signalOnline.bind(this); + this.tooltipTimeouts = []; }, /** * @@ -680,6 +681,9 @@ const Wysiwyg = Widget.extend({ window.removeEventListener('offline', this._checkConnectionChange); } window.removeEventListener('beforeunload', this._onBeforeUnload); + for (const timeout of this.tooltipTimeouts) { + clearTimeout(timeout); + } this._super(); }, /** @@ -1700,16 +1704,19 @@ const Wysiwyg = Widget.extend({ if (isInMedia || (link && link.isContentEditable)) { // Handle the media/link's tooltip. this.showTooltip = true; - setTimeout(() => { + this.tooltipTimeouts.push(setTimeout(() => { // Do not show tooltip on double-click and if there is already one if (!this.showTooltip || $target.attr('title') !== undefined) { return; } this.odooEditor.observerUnactive(); - $target.tooltip({title: _t('Double-click to edit'), trigger: 'manual', container: 'body'}).tooltip('show'); + // Tooltips need to be cleared before leaving the editor. + this.saving_mutex.exec(() => { + $target.tooltip({title: _t('Double-click to edit'), trigger: 'manual', container: 'body'}).tooltip('show'); + }); this.odooEditor.observerActive(); - setTimeout(() => $target.tooltip('dispose'), 800); - }, 400); + this.tooltipTimeouts.push(setTimeout(() => $target.tooltip('dispose'), 800)); + }, 400)); } // Update color of already opened colorpickers. setTimeout(() => {