Skip to content

Commit 2d0f9f1

Browse files
authored
fix: filters query params (#515)
1 parent 2d3cde6 commit 2d0f9f1

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/unfold/static/unfold/js/app.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,27 @@ window.addEventListener("load", (e) => {
66
dateTimeShortcutsOverlay();
77

88
renderCharts();
9+
10+
filterForm();
911
});
1012

13+
/*************************************************************
14+
* Filter form
15+
*************************************************************/
16+
const filterForm = () => {
17+
const filterForm = document.getElementById("filter-form");
18+
19+
if (!filterForm) {
20+
return;
21+
}
22+
23+
filterForm.addEventListener("formdata", (event) => {
24+
Array.from(event.formData.entries()).forEach(([key, value]) => {
25+
if (value === "") event.formData.delete(key);
26+
});
27+
});
28+
};
29+
1130
/*************************************************************
1231
* Class watcher
1332
*************************************************************/

src/unfold/templates/unfold/change_list_filter.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h3 class="border-b flex font-medium mb-6 px-6 py-4 text-gray-700 text-sm dark:t
2121

2222
<div class="px-6{% if cl.model_admin.list_filter_submit %} pb-16{% endif %}">
2323
{% if cl.model_admin.list_filter_submit %}
24-
<form method="get">
24+
<form id="filter-form" method="get">
2525
{% endif %}
2626

2727

0 commit comments

Comments
 (0)