Skip to content

Commit 4cfe1ca

Browse files
committed
Prevent page refresh if present result is same as result to be searched
1 parent 7a2077b commit 4cfe1ca

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

frontend/src/static/js/components/webstatus-overview-filters.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import {
5454

5555
import {CSVUtils} from '../utils/csv.js';
5656
import {Toast} from '../utils/toast.js';
57+
import {navigateToUrl} from '../utils/app-router.js';
5758

5859
const WEBSTATUS_FEATURE_OVERVIEW_CSV_FILENAME =
5960
'webstatus-feature-overview.csv';
@@ -233,7 +234,7 @@ export class WebstatusOverviewFilters extends LitElement {
233234
q: (this.typeaheadRef.value as WebstatusTypeahead).value,
234235
start: 0,
235236
});
236-
window.location.href = newUrl;
237+
navigateToUrl(newUrl);
237238
}
238239

239240
protected firstUpdated(): void {

frontend/src/static/js/utils/app-router.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ export const navigateToUrl = (url: string, event?: MouseEvent) => {
5555
return;
5656
}
5757

58+
const oldPath = window.location.pathname + window.location.search;
59+
if (oldPath === url) {
60+
return; // Prevents unnecessary navigation
61+
}
62+
5863
// TODO. We should use the vaadin router and use the navigate method there.
5964
window.location.href = url;
6065
};

0 commit comments

Comments
 (0)