Skip to content

Commit d98d3dd

Browse files
committed
fix(ui): scope data-search-count lookup to the filter widget
v2-search-filter resolved `list` relative to `[data-search-scope]` but then picked `count` via a global `document.querySelector`. That works on current pages (one widget per page) but is a footgun: the moment a second filter widget ships on any page (e.g. sidebar facet plus top-of-list), both filters would end up driving the same count element. Applying the same scope/document fallback pattern we already use for `list` — scope first, document fallback for legacy single-widget layouts that put count outside the scope. Per review on PR #571. Signed-off-by: Sebastian Mendel <sebastian.mendel@netresearch.de> Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
1 parent edf6ccb commit d98d3dd

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

internal/web/static/js/v2-search-filter.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@
2424
var items = Array.prototype.slice.call(
2525
list.querySelectorAll("[data-search-item]")
2626
);
27-
var count = document.querySelector("[data-search-count]");
27+
// Keep count scoped consistently with `list` — if more than one
28+
// [data-search-filter] widget is ever rendered on a page the
29+
// document-wide lookup would point every filter at the first
30+
// count element. The document fallback is kept for legacy
31+
// single-widget pages that put the count outside the scope.
32+
var count =
33+
scope.querySelector("[data-search-count]") ||
34+
document.querySelector("[data-search-count]");
2835
var debounceTimer = null;
2936

3037
input.setAttribute("role", "searchbox");

0 commit comments

Comments
 (0)