From 98a0376a1449baf9d595d2cd5c8d50e931319ed2 Mon Sep 17 00:00:00 2001 From: xO-Tx Date: Thu, 30 Sep 2021 06:56:31 +0000 Subject: [PATCH] [FIX] web_editor: fix Theme tab infinite loading ISSUE: The click on "THEME" tab in editor panel triggers the '_onThemeTabClick' method which: 1- Starts the loader ('_execWithLoadingEffect' method). 2- Runs '_activateSnippet' which uses the same mutex as the loader. Execution order: A1- '_execWithLoadingEffect' with promise: adds the loader in the DOM immediately. A2- '_activateSnippet' sets a second loader to be added after a delay = 500. A3- 'releaseLoader' removes the first loader. A4- '_activateSnippet' ends : (before adding the second loader: t(4) - t(2) < 500) and timeout is cleared. In some cases we get t(4) - t(2) > 500 which adds a second loader to the DOM, and the new flow will be: B1- Same as A1. B2- Same as A2. B3- Second loader added to the DOM / replaces the first one in 'loadingElements'. B4- 'releaseLoader' removes the second loader (from the DOM & 'this.loadingElements'). B5- Same as A4 but the first loader still in the DOM. The goal of this commit is to fix this behaviour by preventing more than one loader on the target element. task-2656308 closes odoo/odoo#77500 X-original-commit: 9f21b2eefab2115c1b8581ad9f43fe1e65f934ed Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/static/src/js/editor/snippets.editor.js | 2 +- 1 file changed, 1 insertion(+), 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 8ea0ddfb647..b4e9bcdaa52 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -2576,7 +2576,7 @@ var SnippetsMenu = Widget.extend({ const mutexExecResult = this._mutex.exec(action); if (!this.loadingTimers[contentLoading]) { const addLoader = () => { - if (this._loadingEffectDisabled) { + if (this._loadingEffectDisabled || this.loadingElements[contentLoading]) { return; } this.loadingElements[contentLoading] = this._createLoadingElement();