From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id CEB42B9FDE for ; Mon, 18 Mar 2024 14:44:56 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id ABD7311C18 for ; Mon, 18 Mar 2024 14:44:56 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 18 Mar 2024 14:44:55 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 595234654B for ; Mon, 18 Mar 2024 14:44:55 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Mon, 18 Mar 2024 14:44:54 +0100 Message-Id: <20240318134454.2908174-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.019 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [RFC PATCH widget-toolkit] utils: API2Request: defer masking after layout X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Mar 2024 13:44:56 -0000 since some time (not sure when exactly), the 'load()' method of the edit window did not correctly mask the window anymore the reason seems to be that the API2Request tries to mask the component before it's rendered, and that did never work correctly judging from the existing comment. Instead of simply calling `setLoading`, test if the component is rendered, and if not, mask it after it has finished it's layout. Since we cannot guarantee that the 'afterlayout' event is triggered before the api call response handler, add a unique id marker to the waitMsgTarget that is delted when the loading is done, and only trigger the masking if this marker is still there. (thankfully javascript is single threaded so this should not end up being a data race) Signed-off-by: Dominik Csapak --- sending as RFC because i'm unsure if we accidentally broke the masking somewhere along the way. AFAICS from the current code, this never could have worked properly? anyway, i'll be looking into that sometimes soon, and this patch should be correct anyway... src/Utils.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Utils.js b/src/Utils.js index ff7c1a7..b5e12f3 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -458,6 +458,7 @@ utilities: { newopts.url = '/api2/extjs' + newopts.url; } delete newopts.callback; + let loadingId = `loading${++Ext.idSeed}`; let createWrapper = function(successFn, callbackFn, failureFn) { Ext.apply(newopts, { @@ -467,6 +468,7 @@ utilities: { options.waitMsgTarget.setMasked(false); } else { options.waitMsgTarget.setLoading(false); + delete options.waitMsgTarget[loadingId]; } } let result = Ext.decode(response.responseText); @@ -489,6 +491,7 @@ utilities: { options.waitMsgTarget.setMasked(false); } else { options.waitMsgTarget.setLoading(false); + delete options.waitMsgTarget[loadingId]; } } response.result = {}; @@ -518,9 +521,15 @@ utilities: { if (target) { if (Proxmox.Utils.toolkit === 'touch') { target.setMasked({ xtype: 'loadmask', message: newopts.waitMsg }); - } else { - // Note: ExtJS bug - this does not work when component is not rendered + } else if (target.rendered) { target.setLoading(newopts.waitMsg); + } else { + target[loadingId] = true; + target.on('afterlayout', function() { + if (target[loadingId]) { + target.setLoading(newopts.waitMsg); + } + }, target, { single: true }); } } Ext.Ajax.request(newopts); -- 2.39.2