Fix Blog List block ignoring its tag/sort filters (#1159) - #1160
Open
rustynwac wants to merge 1 commit into
Open
Fix Blog List block ignoring its tag/sort filters (#1159)#1160rustynwac wants to merge 1 commit into
rustynwac wants to merge 1 commit into
Conversation
In dynamic mode the block resolved the selected tag slugs and sort into a local query-params object that was never used: the request it issued to the posts API carried only the limit, so the API returned unfiltered recent posts and off-tag posts rendered (e.g. a News post in a list filtered to Climbing Forecast). The "View all" link was built from the same unused params, so it dropped the filters too. Send the selected tags and sort to `/api/[center]/posts` (which already filters on tags.slug and applies sort) and reuse the same params for the "View all" /blog link, which reads the same `tags`/`sort` query params. Removed the write-only `postsPageParams` from the effect deps so the fetch doesn't run twice on mount. Fixes #1159 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016s7MJjeP8Mr3KRiRA22WwJ
Contributor
|
Preview deployment: https://claudexbloglist-tag-filter-1159.preview.avy-fx.org |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Blog List block's dynamic mode ignored its Filter by Tag(s) (and sort) selection — e.g. on the MSAC Climbing Forecast page, a block filtered to
Climbing Forecastalso showed aNews-tagged post (#1159, confirmed reproducible across tenants).Root cause: the block resolved the selected tag slugs + sort into a local
URLSearchParamsthat was then never used. The request it actually issued was/api/[center]/posts?limit=Nwith notags, so the API returned unfiltered recent posts. The "View all" link had the same defect (built from the empty params object), so it dropped the filters too. The posts API andgetPostsquery already filter ontags.slugand applysortcorrectly — the bug was entirely in the block's client component.Related Issues
Fixes #1159
Key Changes
src/blocks/BlogList/Component.tsx— build onefilterParams(sort+ comma-joinedtagsslugs) and actually send it: the posts API fetch getsfilterParams+limit, and the "View all" link reusesfilterParams(the/bloglisting reads the sametags/sortparams). Also dropped the write-onlypostsPageParamsfrom the effect's dependency array so the fetch no longer runs twice on mount.No API/query changes — the backend was already correct.
How to test
pnpm seed, thenpnpm dev./blogview filtered to the same tag.Verification performed: drove the exact contract the component now uses against a seeded DB via the running dev server —
/api/nwac/postswith no filter returned all 3 posts (including off-tag ones, i.e. the bug),?tags=educationreturned only the matching post, and?tags=education,gearreturned both (OR semantics). The component now sendstags/sortinto that fetch.Automated:
pnpm tsc,pnpm lint,pnpm test(525 passing),pnpm fallow:auditandpnpm fallow:checkall green.Migration Explanation
None — no schema changes.
Future enhancements / Questions
None.
🤖 Generated with Claude Code
https://claude.ai/code/session_016s7MJjeP8Mr3KRiRA22WwJ
Generated by Claude Code
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.