Skip to content

Search 3.0: add compact search block template#48433

Draft
adamwoodnz wants to merge 1 commit intotrunkfrom
cursor/add-compact-search-template-403f
Draft

Search 3.0: add compact search block template#48433
adamwoodnz wants to merge 1 commit intotrunkfrom
cursor/add-compact-search-template-403f

Conversation

@adamwoodnz
Copy link
Copy Markdown
Contributor

Fixes #

Proposed changes

  • Register a second Jetpack Search block template, "Jetpack Search Results (Compact)", that mirrors the Compact Search pattern (toolbar layout: search input + filter popover + sort popover over a layout="compact" results list).
  • Surface the new template alongside the existing sidebar template in the Site Editor's Templates list (Appearance → Editor → Templates → Add New) so site owners can opt into the compact layout without editing the default template or hand-building the pattern.
  • Refactor Search_Blocks::get_search_template_content() to take a slug argument (memoized per slug) so register_search_template() can register both templates from one code path.

The compact slug is intentionally not prepended to search_template_hierarchy — only one plugin template should win the /?s=… lookup, and the layout-rich sidebar template (jetpack-search) remains the default. Site owners who want the compact layout to take over /?s=… can either edit the resolved search template in the Site Editor or assign the compact template to a page.

Related product discussion/links

  • Linear issue: RSM-1944 — Add search template with compact search

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  1. Build the search package (or run a Jetpack site that loads it) with jetpack_search_blocks_enabled true and the search-blocks bundle registered.
  2. In Appearance → Editor → Templates, click Add New Template.
  3. Confirm both Jetpack Search Results and Jetpack Search Results (Compact) appear in the list of plugin-registered templates.
  4. Add the Jetpack Search Results (Compact) template to a page (or open it in the Site Editor) and confirm the rendered layout matches the Compact Search block pattern: a single-row toolbar (search input + filter popover + sort popover) over a compact result list, no sidebar column.
  5. Visit /?s=test and confirm the default sidebar layout still resolves (i.e. the compact template did not take over the search hierarchy).
  6. Run the package PHP tests:
    jp test php packages/search
    All Search_Blocks_Test cases (including the two new ones — test_register_search_template_registers_compact_variant and the updated empty-content / hierarchy assertions) should pass.

Test results

PHPUnit 12.5.23 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.18
Configuration: /workspace/projects/packages/search/phpunit.11.xml.dist

...............................................................  63 / 229 ( 27%)
............................................................... 126 / 229 ( 55%)
............................................................... 189 / 229 ( 82%)
........................................                        229 / 229 (100%)

Time: 00:00.268, Memory: 62.50 MB

OK (229 tests, 406 assertions)

Linear Issue: RSM-1944

Open in Web Open in Cursor 

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the cursor/add-compact-search-template-403f branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack cursor/add-compact-search-template-403f

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Package] Search Contains core Search functionality for Jetpack and Search plugins [Status] In Progress [Tests] Includes Tests labels May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label May 1, 2026
@adamwoodnz adamwoodnz self-assigned this May 1, 2026
@adamwoodnz adamwoodnz removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label May 1, 2026
@jp-launch-control
Copy link
Copy Markdown

jp-launch-control Bot commented May 1, 2026

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/search/src/search-blocks/class-search-blocks.php 216/344 (62.79%) 1.41% -1 💚

Full summary · PHP report · JS report

Registers a second plugin-origin block template,
'Jetpack Search Results (Compact)', that mirrors the Compact Search
pattern (toolbar layout: search input + filter popover + sort popover
over a layout="compact" result list). Surfaces alongside the existing
sidebar template in the Site Editor's Templates list so site owners can
opt into the compact layout without having to edit the default template
or hand-build the pattern.

The compact slug is intentionally NOT prepended to
search_template_hierarchy; only one plugin template should win the
/?s=... lookup, and the layout-rich sidebar template remains the default.

Refactors get_search_template_content() to take a slug argument and
memoize per slug, so register_search_template() can register both
templates from the same code path.

Co-authored-by: Adam Wood <adamwoodnz@users.noreply.github.com>
@adamwoodnz adamwoodnz force-pushed the cursor/add-compact-search-template-403f branch from fbe59c4 to dcf77ba Compare May 7, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Search Contains core Search functionality for Jetpack and Search plugins [Status] In Progress [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants