From c7a559f78cda174eff2ac6564cb868d2d15d976a Mon Sep 17 00:00:00 2001 From: David Miculit Date: Wed, 22 Apr 2026 16:28:48 +0300 Subject: [PATCH 1/2] fix: make use replicates button work on first click and not force a page refresh --- ui/perfherder/graphs/GraphsView.jsx | 37 ++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/ui/perfherder/graphs/GraphsView.jsx b/ui/perfherder/graphs/GraphsView.jsx index e270d60476b..0dd4ecec687 100644 --- a/ui/perfherder/graphs/GraphsView.jsx +++ b/ui/perfherder/graphs/GraphsView.jsx @@ -102,7 +102,6 @@ function GraphsView({ projects, frameworks, user }) { repository_name: repositoryName, signature_id: signatureId, framework_id: frameworkId, - replicates: seriesReplicates, } = series; return { @@ -111,7 +110,7 @@ function GraphsView({ projects, frameworks, user }) { framework: frameworkId, interval: timeRangeRef.current.value, all_data: true, - replicates: seriesReplicates, + replicates: replicatesRef.current, }; }, []); @@ -319,6 +318,10 @@ function GraphsView({ projects, frameworks, user }) { ); const updateStateParams = useCallback((state) => { + const replicatesChanged = + state.replicates !== undefined && + state.replicates !== replicatesRef.current; + if (state.testData !== undefined) setTestData(state.testData); if (state.selectedDataPoint !== undefined) setSelectedDataPoint(state.selectedDataPoint); @@ -335,11 +338,24 @@ function GraphsView({ projects, frameworks, user }) { setHighlightedRevisions(state.highlightedRevisions); if (state.visibilityChanged !== undefined) setVisibilityChanged(state.visibilityChanged); - if (state.replicates !== undefined) setReplicates(state.replicates); if (state.colors !== undefined) setColors(state.colors); if (state.symbols !== undefined) setSymbols(state.symbols); - pendingChangeParams.current = true; - }, []); + + if (state.replicates !== undefined) { + setReplicates(state.replicates); + replicatesRef.current = state.replicates; + } + + if (replicatesChanged) { + setZoom({}); + setSelectedDataPoint(null); + setColors([...graphColors]); + setSymbols([...graphSymbols]); + getTestData(); + } else { + pendingChangeParams.current = true; + } + }, [getTestData]); // componentDidMount - check query params useEffect(() => { @@ -423,11 +439,6 @@ function GraphsView({ projects, frameworks, user }) { if (prevSearch === location.search) return; - const { replicates: currentReplicates } = queryString.parse( - location.search, - ); - const { replicates: prevReplicates } = queryString.parse(prevSearch); - if ( location.search === '' && testDataRef.current.length !== 0 && @@ -435,12 +446,6 @@ function GraphsView({ projects, frameworks, user }) { ) { setTestData([]); } - - if (prevReplicates !== undefined) { - if (currentReplicates !== prevReplicates) { - window.location.reload(false); - } - } }, [location.search, loading]); const handleUpdateTimeRange = useCallback( From 92405ec5757dbe60f580c912fc3295bc2b5ef489 Mon Sep 17 00:00:00 2001 From: David Miculit Date: Tue, 28 Apr 2026 15:31:56 +0300 Subject: [PATCH 2/2] fix: sync replicates ref before any fetches occur --- ui/perfherder/graphs/GraphsView.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/perfherder/graphs/GraphsView.jsx b/ui/perfherder/graphs/GraphsView.jsx index 0dd4ecec687..15b21a0bbc6 100644 --- a/ui/perfherder/graphs/GraphsView.jsx +++ b/ui/perfherder/graphs/GraphsView.jsx @@ -373,6 +373,11 @@ function GraphsView({ projects, frameworks, user }) { const updates = {}; + if (replicatesParam) { + updates.replicates = Boolean(parseInt(replicatesParam, 10)); + replicatesRef.current = updates.replicates; + } + if (series) { const _series = typeof series === 'string' ? [series] : series; const seriesParams = parseSeriesParam( @@ -396,9 +401,6 @@ function GraphsView({ projects, frameworks, user }) { parseInt(hlInitialDataPoints, 10), ); } - if (replicatesParam) { - updates.replicates = Boolean(parseInt(replicatesParam, 10)); - } if (hlRevisions) { updates.highlightedRevisions = typeof hlRevisions === 'string' ? [hlRevisions] : hlRevisions;