From 86a207e191aa0b28bfc1a4d9e9331073ff47c34d Mon Sep 17 00:00:00 2001
From: MariaPaula Trujillo
Date: Thu, 12 Sep 2024 19:30:10 +0200
Subject: [PATCH] Fix clear filters bug and update link href
---
static/js/src/cve/cve.js | 17 ++++++++---------
templates/security/cves/index.html | 2 +-
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/static/js/src/cve/cve.js b/static/js/src/cve/cve.js
index 7dd17885b27..480064dd7ec 100644
--- a/static/js/src/cve/cve.js
+++ b/static/js/src/cve/cve.js
@@ -212,15 +212,14 @@ handleFilterPersist();
function handleClearFilters() {
if (clearFiltersButton) {
clearFiltersButton.addEventListener("click", function (event) {
- for (const [param] of urlParams.entries()) {
- if (urlParams.has("q")) {
- if (param != "q") {
- urlParams.delete(param);
- }
- } else {
- urlParams.append("q", "");
- }
- }
+ let keys = [...urlParams.keys()];
+ keys.forEach((key) => {
+ urlParams.delete(key);
+ });
+ // Always leave this empty param on clear
+ // so the user is not redirected to the landing page
+ urlParams.set("q", "");
+
url.search = urlParams.toString();
window.location.href = url.href;
});
diff --git a/templates/security/cves/index.html b/templates/security/cves/index.html
index 8ff57dd418c..876b2eaf200 100644
--- a/templates/security/cves/index.html
+++ b/templates/security/cves/index.html
@@ -29,7 +29,7 @@ CVE reports