Wire facet droppers to context-aware counts (frontend for #12978)#13064
Wire facet droppers to context-aware counts (frontend for #12978)#13064Armansiddiqui9 wants to merge 3 commits into
Conversation
Extends item shape from {value, label} to {value, label, count?}.
Renders count as a muted, comma-formatted trailing number when present.
Adds host-driven loading boolean attribute, swaps suggestions list for
a spinner while true. No fetch or domain logic added - stays a pure
UI component per the building-components architecture guide.
Part of internetarchive#13060
for more information, see https://pre-commit.ci
|
Thanks for the contribution, @Armansiddiqui9! 🤖 Copilot has been assigned for an initial review. The linked issue (#13060) hasn't been triaged yet — triage happens on Mondays and Fridays. There are currently 27 open non-draft PRs ahead of yours. PR triage checklist (maintainers / Richy)
Note This comment was automatically generated by PAM, Open Library's Project AI Manager. PAM provides status visibility, performs basic project management functions, and gives actionable feedback so contributors aren't left waiting. |
|
This is looking great. Once the backend work is complete we'll do one more pass. At that point, if you could record a short video of the feature working, including the new loading indicator, that would be really helpful. I'm encouraging all of us to add videos to UI-related PRs. They convey a lot about the scope of a feature, get people excited, and give reviewers confidence that the change has actually been tested. |
Closes #13060
Depends on #12980 (backend API, currently WIP — see note below)
Feature
Makes the Language filter on
/searchreflect the current search insteadof always showing the full catalogue. When a patron has an active query,
opening the Language dropper now shows only languages with matching
results, with a count next to each, sorted by relevance, no more dead-end
selections that silently return zero books.
Technical
OlSelectPopover.js— extended item shape to{value, label, count?}.Renders count as a muted, comma-formatted trailing number. Added a
loadingattribute for a host-driven spinner state. No fetch or domainlogic added — stays a pure UI component per the
building-components guide.
search-modal/searchFacets.js(new) — service module owning the/search/facets.jsoncall. ExposesfetchFacetCounts(field, searchParams).SearchFilterBar.js— orchestration. Onol-popover-open, fetchesthe language catalogue and facet counts in parallel, merges by MARC code,
sorts descending, hides zero-count values (keeps the current selection
visible even at 0 so it can still be unticked). Falls back to the
uncounted catalogue on error or when there's no active query.
searchFacets.test.js(new) — 16 unit tests covering the servicemodule's response handling and the merge/sort/hide-zero logic. All passing.
Testing
npm run test:js— 483/483 passing (including the 16 new tests)/search/facets.json(since feat(search): add GET /search/facets.json — context-aware facet values API #12980 is still WIP) and verified againstthe real
/languages.jsoncatalogue. Confirmed counts render correctly,comma-formatted, sorted descending, zero-count items hidden, loading
state visible during fetch.
q=is empty)Open question for @RayBB
Confirmed locally that the frontend's language catalogue keys
valueonMARC code (
eng,fre,ger...) via/languages.json, not thedisplay name. Please make sure
/search/facets.json'svaluefieldreturns matching MARC codes, not full language names — otherwise the
merge in
SearchFilterBar.jswill silently match nothing and the dropperwill render empty. Happy to pair on this if useful.
Stakeholders
@lokesh @RayBB