From f2fa17540e130b5cf3f70570a3a97495cfbb7499 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Thu, 28 Jan 2021 13:17:22 +0000 Subject: [FIX] website, web_editor: ensure the loader appears on click options Before this commit the loader did not always get displayed when switching to the options tab. After this commit the loader always gets displayed ASAP when switching to the options tab until the tab is ready and displayed. task-2439295 https://github.com/odoo/odoo/pull/65223 Co-authored-by: Samuel Degueldre --- addons/web_editor/static/src/js/editor/snippets.editor.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'addons/web_editor/static') 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 cf194d45082..3997e6df15c 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -2216,22 +2216,29 @@ var SnippetsMenu = Widget.extend({ async _execWithLoadingEffect(action, contentLoading = true, delay = 500) { const mutexExecResult = this._mutex.exec(action); if (!this.loadingTimers[contentLoading]) { - this.loadingTimers[contentLoading] = setTimeout(() => { + const addLoader = () => { this.loadingElements[contentLoading] = this._createLoadingElement(); if (contentLoading) { this.$snippetEditorArea.append(this.loadingElements[contentLoading]); } else { this.el.appendChild(this.loadingElements[contentLoading]); } - }, delay); + }; + if (delay) { + this.loadingTimers[contentLoading] = setTimeout(addLoader, delay); + } else { + addLoader(); + } this._mutex.getUnlockedDef().then(() => { // Note: we remove the loading element at the end of the // execution queue *even if subsequent actions are content // related or not*. This is a limitation of the loading feature, // the goal is still to limit the number of elements in that // queue anyway. - clearTimeout(this.loadingTimers[contentLoading]); - this.loadingTimers[contentLoading] = undefined; + if (delay) { + clearTimeout(this.loadingTimers[contentLoading]); + this.loadingTimers[contentLoading] = undefined; + } if (this.loadingElements[contentLoading]) { this.loadingElements[contentLoading].remove(); -- cgit v1.2.3