Skip to content

Pattern directory theme: keep the curation and sort filters when searching - #781

Merged
gedex merged 2 commits into
trunkfrom
fix/search-keeps-filters
Sep 28, 2026
Merged

gedex merged 2 commits into
trunkfrom
fix/search-keeps-filters

Conversation

@gedex

@gedex gedex commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Searching resets the Curated/All filter, so a search from ?curation=all only returns curated patterns. The search form now keeps the curation and sorting, like it already does for the category.

See #709 (comment)

Fixes #709

Testing

  1. Go to http://localhost:8888/?curation=all.
  2. Search for "404".
  3. The URL becomes ?s=404&curation=all instead of ?s=404, so the curation parameter isn't dropped. The filter still says All, and results show up.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Search forms on the site now retain selected categories, curation, sort order, and sort field when submitted.
    • Forms whose action does not match the site’s home URL remain unchanged.

…ching

Searching from `?curation=all` dropped the filter and only returned curated
patterns. The search form now carries the current curation and sorting, like
it already did for the category. The header search is left alone.

See #709.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

Next included review available in 14 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 08cbebe0-7152-4a83-ab31-5f6833c62f80

📥 Commits

Reviewing files that changed from the base of the PR and between 5110778 and 484d340.

📒 Files selected for processing (1)
  • public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: c49dabf5-496e-4c04-ac84-71c16b980d5e

📥 Commits

Reviewing files that changed from the base of the PR and between 4482f38 and 5110778.

📒 Files selected for processing (1)
  • public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

The search-block render filter now uses inject_filters_search_block. The handler leaves forms with no matching first action unchanged and adds hidden inputs for pattern-categories, curation, order, and orderby when the action matches the site home URL.

Changes

Search filter preservation

Layer / File(s) Summary
Search form filter handling
public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php
The render filter calls the renamed handler. The handler checks the first form action and appends hidden inputs for the four current filter values when the action matches the site home URL.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: obenland

Merge Risk: ⚪ Minimal · up to 51107

Searching from the pattern directory preserves the selected category, curation, and sorting filters. No material merge risk was identified.

Architecture Summary

Architecture risk: 🔵 Low · up to 51107

The change affects 1 system.

Changed systems: public_html

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — public_html (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php: The search-block render filter now calls inject_filters_search_block instead of the category-only handler.
  • observed — Modified behavior in public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php: The category-only search handler was replaced with one that first checks the first form’s action: if no form is found or its normalized action differs from home_url(), it returns the markup unchanged. For matching forms, it appends hidden inputs for current pattern-categories, curation, order, and orderby values; previously it appended only pattern-categories values without checking the form action.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main change: preserving curation and sorting filters during searches.
Description check ✅ Passed The description explains the problem, the intended behavior, the related issue, and the test steps. The optional Props and screenshots sections are not included, but they are not required for this non…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gedex gedex self-assigned this Sep 28, 2026
@gedex
gedex requested a lite review from Copilot September 28, 2026 13:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Updates the pattern directory search form to preserve active filters when searching.

Changes:

  • Retains category, curation, and sorting parameters.
  • Limits injection to forms targeting the site homepage.
File Summary
public_html/​wp-content/​themes/​wporg-pattern-directory-2024/​inc/​block-config.php Preserves active filters in pattern searches.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@gedex

gedex commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author
before after
Screen.Recording.2026-09-28.at.20.35.09.mov
Screen.Recording.2026-09-28.at.20.34.31.mov

@gedex
gedex requested a review from bor0 September 28, 2026 13:36

@bor0 bor0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Checked a few things:

  • Checking the form action also fixes another bug. On production, /patterns/categories/header/?curation=all&orderby=date&order=asc currently adds pattern-categories=header to the global header search too (the one that submits to wordpress.org/search/do-search.php). This PR skips that form.
  • The action check matches production: the patterns search form's action is https://wordpress.org/patterns/, which is the same as home_url() once the trailing slash is removed.
  • The added query vars are the same ones inject_other_filters() carries. redirect_term_archives() already keeps curation/order/orderby when it redirects to a category archive, so they aren't lost there.

Optional nit: the header search is only skipped because swap_header_search_action (wporg-mu-plugins, same hook, priority 10) runs first, since mu-plugins load before the theme. If that order changed, the header form would still have action="home_url('/')" when this filter runs. A short comment, or also skipping blocks with a formAction attribute, would make it safe either way.

The global header search was only skipped because the mu-plugin swaps its
action before this filter runs. Checking `formAction` keeps it skipped
whatever order the filters run in.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@gedex

gedex commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for checking, @bor0. Good catch on the filter order. 484d340 skips any search block with a formAction attribute, so the header search is left alone whichever filter runs first. I tested it by making the header's action swap run after this filter. The old code added the category and curation to the header search, the new code doesn't.

@gedex
gedex merged commit eaa24d0 into trunk Sep 28, 2026
5 checks passed
@gedex
gedex deleted the fix/search-keeps-filters branch September 28, 2026 14:10
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.

Default curation filter makes it seem like very few patterns exist

3 participants