From 1b043838eac01b1c45f78e5f26fcdc5858361326 Mon Sep 17 00:00:00 2001 From: Christoph Kluge Date: Fri, 14 Feb 2025 16:18:58 +0100 Subject: [PATCH] fix: fix svelte js race condition on metric selection change, see #335 - only dispatch new data to statsTable on 'load-all' --- web/frontend/src/job/Metric.svelte | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/web/frontend/src/job/Metric.svelte b/web/frontend/src/job/Metric.svelte index b61ed13..bcfa4fd 100644 --- a/web/frontend/src/job/Metric.svelte +++ b/web/frontend/src/job/Metric.svelte @@ -148,17 +148,18 @@ zoomState = {...pendingZoomState} } - // Set selected scope to min of returned scopes + // On additional scope request if (selectedScope == "load-all") { + // Push scope to statsTable (Needs to be in this case, else newly selected 'Metric.svelte' renders cause statsTable race condition) + const statsTableData = $metricData.data.singleUpdate.filter((x) => x.scope !== "node") + if (statsTableData.length > 0) { + dispatch("more-loaded", statsTableData); + } + // Set selected scope to min of returned scopes selectedScope = minScope(scopes) nodeOnly = (selectedScope == "node") // "node" still only scope after load-all } - const statsTableData = $metricData.data.singleUpdate.filter((x) => x.scope !== "node") - if (statsTableData.length > 0) { - dispatch("more-loaded", statsTableData); - } - patternMatches = statsPattern.exec(selectedScope) if (!patternMatches) {