Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c7f618f

Browse files
committed
Remove refresh hack for metric selector
Now the metric quick links will be triggered using JS and not as a normal HTML link, but as an advantage, we won't need to force refresh the component from the outside whenever the URL changes.
1 parent d77228a commit c7f618f

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

site/frontend/src/pages/compare/compile/compile-page.vue

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,9 @@ function storeFilterToUrl(
126126
changeUrl(urlParams);
127127
}
128128
129-
/**
130-
* When the filter changes, the URL is updated.
131-
* After that happens, we want to re-render the quick links component, because
132-
* it contains links that are "relative" to the current URL. Changing this
133-
* key ref will cause it to be re-rendered.
134-
*/
135-
function refreshQuickLinks() {
136-
quickLinksKey.value += 1;
137-
}
138-
139129
function updateFilter(newFilter: CompileBenchmarkFilter) {
140130
storeFilterToUrl(newFilter, defaultCompileFilter, getUrlParams());
141131
filter.value = newFilter;
142-
refreshQuickLinks();
143132
}
144133
145134
function exportData() {
@@ -148,7 +137,6 @@ function exportData() {
148137
149138
const urlParams = getUrlParams();
150139
151-
const quickLinksKey = ref(0);
152140
const filter = ref(loadFilterFromUrl(urlParams, defaultCompileFilter));
153141
154142
const benchmarkMap = createCompileBenchmarkMap(props.data);
@@ -166,11 +154,7 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
166154
</script>
167155

168156
<template>
169-
<MetricSelector
170-
:metric="selector.stat"
171-
:key="quickLinksKey"
172-
:benchmark-info="benchmarkInfo"
173-
/>
157+
<MetricSelector :metric="selector.stat" :benchmark-info="benchmarkInfo" />
174158
<Filters
175159
:defaultFilter="defaultCompileFilter"
176160
:initialFilter="filter"

site/frontend/src/pages/compare/metric-selector.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ function createMetric(
2222
return {label, metric, description};
2323
}
2424
25-
function createUrlForMetric(metric: string): URL {
25+
function navigateToMetric(metric: string) {
2626
const params = {stat: metric};
27-
return createUrlWithAppendedParams(params);
27+
const url = createUrlWithAppendedParams(params);
28+
navigateToUrlParams(url.searchParams);
2829
}
2930
3031
function changeMetric(e: Event) {
3132
const target = e.target as HTMLSelectElement;
3233
const metric = target.value;
33-
navigateToUrlParams(createUrlForMetric(metric).searchParams);
34+
navigateToMetric(metric);
3435
}
3536
3637
const metrics = [
@@ -58,7 +59,7 @@ const metrics = [
5859
:class="{active: props.metric === metric.metric}"
5960
:title="metric.description"
6061
>
61-
<a :href="createUrlForMetric(metric.metric).toString()">{{
62+
<a href="#" @click.prevent="() => navigateToMetric(metric.metric)">{{
6263
metric.label
6364
}}</a>
6465
</div>

0 commit comments

Comments
 (0)