diff options
| author | Benoit Socias <bso@odoo.com> | 2021-01-28 13:17:22 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2021-02-15 15:49:15 +0000 |
| commit | f2fa17540e130b5cf3f70570a3a97495cfbb7499 (patch) | |
| tree | 0233ff281b396df6bbccaf62bef0d6df35331f1a /addons/web_editor/static/src/js | |
| parent | 768bcf58e8dc215b96b11bafa632c07dc683e297 (diff) | |
[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 <sad@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src/js')
| -rw-r--r-- | addons/web_editor/static/src/js/editor/snippets.editor.js | 15 |
1 files changed, 11 insertions, 4 deletions
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(); |
