Skip to content

Fix Blog List block ignoring its tag/sort filters (#1159) - #1160

Open
rustynwac wants to merge 1 commit into
mainfrom
claude/bloglist-tag-filter-1159
Open

Fix Blog List block ignoring its tag/sort filters (#1159)#1160
rustynwac wants to merge 1 commit into
mainfrom
claude/bloglist-tag-filter-1159

Conversation

@rustynwac

@rustynwac rustynwac commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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 Forecast also showed a News-tagged post (#1159, confirmed reproducible across tenants).

Root cause: the block resolved the selected tag slugs + sort into a local URLSearchParams that was then never used. The request it actually issued was /api/[center]/posts?limit=N with no tags, 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 and getPosts query already filter on tags.slug and apply sort correctly — the bug was entirely in the block's client component.

Related Issues

Fixes #1159

Key Changes

  • src/blocks/BlogList/Component.tsx — build one filterParams (sort + comma-joined tags slugs) and actually send it: the posts API fetch gets filterParams + limit, and the "View all" link reuses filterParams (the /blog listing reads the same tags/sort params). Also dropped the write-only postsPageParams from 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

  1. pnpm seed, then pnpm dev.
  2. On a center with a dynamic Blog List block filtered by a tag, confirm only posts carrying that tag appear, and that the "View all" button lands on a /blog view filtered to the same tag.
  3. A block with no tag selected still shows recent posts up to its limit.

Verification performed: drove the exact contract the component now uses against a seeded DB via the running dev server — /api/nwac/posts with no filter returned all 3 posts (including off-tag ones, i.e. the bug), ?tags=education returned only the matching post, and ?tags=education,gear returned both (OR semantics). The component now sends tags/sort into that fetch.

Automated: pnpm tsc, pnpm lint, pnpm test (525 passing), pnpm fallow:audit and pnpm fallow:check all 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


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

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
@github-actions

Copy link
Copy Markdown
Contributor

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.

Blog List block not respecting filter tags

2 participants