Skip to content

Implement fact check filters#32

Merged
maquchizi merged 7 commits into
mainfrom
implement-fact-check-filters
Jun 29, 2026
Merged

Implement fact check filters#32
maquchizi merged 7 commits into
mainfrom
implement-fact-check-filters

Conversation

@maquchizi

Copy link
Copy Markdown
Collaborator

Summary

  • Make the /fact-checks grid filter server-side (region/topic/language) instead of the prior placeholder client-side-on-current-page filtering, which narrowed live results to empty. Filters map to real Superdesk taxonomy — region → countries, topic → 01harm, language → swp_article_metadata.language — and are folded into the same swp_article_bool_exp where + aggregate as the existing pagination, so counts/pages stay correct (AND across dimensions, OR within one).
  • Filter state lives in the URL (?region=…&topic=…&language=…&page=), so it's shareable and survives reload/back-forward. Options are editorial {code,label} maps: the normalized subject relation exposes no display name, no reverse relation, and no tenant scope, so a scoped/labeled option list can't be queried (documented in track-a-tasks.md).
  • mapStory now populates region/topic/language labels from the jsonb, and TaxonomyRow renders only present dimensions (no more "Topic · Region · Language" placeholder leak on live cards).
  • UX fixes: removing a chip re-queries immediately (not just on Apply); the filter bar reserves the chip row's height so adding a filter no longer shifts the page; an out-of-range ?page= clamps to the last valid page instead of showing a false "no matches"; dropdowns close on any click outside their options.

Test plan

  • Load /fact-checks → full grid, no filters applied.
  • Apply Topic = Political → grid narrows, URL shows ?topic=polit_harm, count/pagination reflect the filtered total.
  • Combine Region + Topic → results AND-narrow; reload the filtered URL → state restored.
  • Remove a chip → list and URL update immediately, other filters preserved; Clear → full grid.
  • Visit ?topic=…&page=99 → shows last valid page, not an empty "no matches".
  • Open a dropdown, click elsewhere in the bar/page → it closes; click an option → stays open.
  • pnpm test, tsc, biome clean (70 tests; new coverage for buildFactCheckWhere, URL helpers, and mapStory taxonomy).

Closes #30

  * This feels snappier and more natural. It also prevents an empty
    listing when all filters are removed manually i.e. without using the
    "Clear Filters" option
  * Clicking anywhere outside the filter dropdown now closes the
    dropdown. Previously, you had to click outside the actual filter bar
    to dismiss a filter dropdown which was annoying
@maquchizi maquchizi requested a review from kelvinkipruto June 26, 2026 13:51
@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pesacheck-ui Ready Ready Preview, Comment Jun 26, 2026 2:14pm

Request Review

  * Selecting a filter now fetches and filters the listing immediately
    instead of requiring the user to click on "Apply Filters"
@maquchizi maquchizi merged commit b7a4f0f into main Jun 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement fact check filters

2 participants