Skip to content

Commit 426b3ac

Browse files
authored
Prevent page refresh if present result is same as result to be searched (#1249)
* Prevent page refresh if present result is same as result to be searched * Use complete url instead of path * Logic should be in utils, use new URL
1 parent c83d2ed commit 426b3ac

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ export const navigateToUrl = (url: string, event?: MouseEvent) => {
5555
return;
5656
}
5757

58+
// Construct a full URL to handle relative paths correctly
59+
const fullNewUrl = new URL(url, window.location.origin).href; // TODO for future - handle try/catch case until we use AppLocation
60+
61+
const currentUrl = window.location.href;
62+
if (currentUrl === fullNewUrl) {
63+
return;
64+
}
65+
5866
// TODO. We should use the vaadin router and use the navigate method there.
5967
window.location.href = url;
6068
};

0 commit comments

Comments
 (0)