details:   https://code.tryton.org/tryton/commit/4a6e16fdbcc2
branch:    default
user:      Cédric Krier <[email protected]>
date:      Thu Apr 16 23:00:54 2026 +0200
description:
        Execute only one menu item and button actions at a time per tab

        Closes #14769
diffstat:

 sao/src/tab.js |  21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diffs (49 lines):

diff -r 852530086b2d -r 4a6e16fdbcc2 sao/src/tab.js
--- a/sao/src/tab.js    Thu Apr 16 22:50:42 2026 +0200
+++ b/sao/src/tab.js    Thu Apr 16 23:00:54 2026 +0200
@@ -18,6 +18,7 @@
                 'class': 'hidden-lg',
             }).appendTo(this.name_el);
             this.view_prm = jQuery.when();
+            this._action_running = false;
         },
         menu_def: function() {
             return [
@@ -167,8 +168,13 @@
                     this.menu_buttons[item.id] = menuitem;
                     link.click(evt => {
                         evt.preventDefault();
-                        if (!menuitem.hasClass('disabled')) {
-                            this[item.id]();
+                        if (!menuitem.hasClass('disabled')
+                            && !this._action_running) {
+                            this._action_running = true;
+                            (this[item.id]() || jQuery.when())
+                                .always(() => {
+                                    this._action_running = false;
+                                });
                         }
                     });
                 } else if (!item && previous) {
@@ -272,17 +278,14 @@
                 }
                 this.buttons[item.id].click(item, event => {
                     var item = event.data;
-                    var button = this.buttons[item.id];
-                    // Use data instead of disabled prop because the action may
-                    // actually disable the button.
-                    if (button.data('disabled')) {
+                    if (this._action_running) {
                         event.preventDefault();
                         return;
                     }
-                    button.data('disabled', true);
+                    this._action_running = true;
                     (this[item.id](this) || jQuery.when())
-                        .always(function() {
-                            button.data('disabled', false);
+                        .always(() => {
+                            this._action_running = false;
                         });
                 });
             };

Reply via email to