Search: auto-switch Results List to Product view for product-scoped searches#48943
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
This comment has been minimized.
This comment has been minimized.
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
|
Claude finished @kangzj's task in 2m 46s —— View job PR Review
Overall this is a well-crafted feature. The WC-gating pattern is followed correctly, the test matrix is thorough, and the layered safeguards (auto-switch → non-Woo collapse) make the render logic robust. A few items worth addressing: Issues1. Help text uses the wrong URL shape (user-visible bug)
help={ __(
'When the search is scoped to products (a ?post_type=product link), show results as a product grid …',
'jetpack-search-pkg'
) }The help text tells authors the trigger URL is Suggested fix: change the example to 'When the search is scoped to products (a ?post_types[]=product link), show results as a product grid regardless of the format above. Turn off to always use the format above.'2.
|
Code Coverage SummaryCoverage changed in 3 files.
|
8553b34 to
adc909b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Claude finished @kangzj's task in 2m 13s —— View job PR Re-Review
All three issues from the previous review have been correctly resolved. Here's the verification: Issues resolved ✅Issue 1 — Help text URL shape ( The toggle's 'When the search is scoped to products (a ?post_types[]=product link), show results as a product grid regardless of the format above. Turn off to always use the format above.'Correct URL shape, no ambiguity. ✓ Issue 2 — The comment now names Issue 3 — Memoization of The no-memo decision is now fully documented in the docblock:
Reasonable tradeoff, well documented. ✓ The default-on behavioral change is now surfaced in the changelog entry, giving site owners advance notice that existing Fresh pass — nothing new to flag
Three-layer WC gating in
The second gate can never be short-circuited by the auto-switch because the auto-switch itself requires Test isolation: JS tests cover all acceptance criteria: toggle visibility gated on WC, default-on, What looks good overallThe layered safeguards, sanitization, WC gating, test matrix, changelog surfacing, and documentation all meet the bar. This PR looks ready to merge. |
This comment has been minimized.
This comment has been minimized.
…earches When a search is scoped to exactly the product post type via the ?post_types[]=product URL parameter, the Results List block now renders in the Product layout automatically instead of the saved format. A new per-block autoProductView attribute (default on, WooCommerce-only inspector toggle) lets authors opt out. Gated behind the existing woocommerce_blocks_enabled() check so it never forces WC-shaped markup on a non-Woo site.
…ment no-memo choice, expand changelog (comment #4483062776)
adc909b to
95f6fdf
Compare
🤖 Review-cycle summary —
|
| Source | Item | Resolution |
|---|---|---|
| claude[bot] (#4483062776) | Help text used ?post_type=product (reroutes to WC shop archive) |
Corrected to ?post_types[]=product — adc909b708 |
| claude[bot] (#4483062776) | render.php inline comment repeated the misleading scalar shape | Rewrote to name the array trigger + point to the helper docblock — adc909b708 |
| claude[bot] (#4483062776) | request_is_product_only() memoization inconsistency |
Documented the deliberate no-memo choice (single call site; mirrors uncached parse_url_filters()) — adc909b708 |
| claude[bot] (#4483062776) | default-on behavioral change not surfaced | Expanded the changelog entry — adc909b708 |
| claude[bot] (#4483134126) | Re-review | All issues verified resolved — "ready to merge" |
| Copilot (#4483140667) | Review | "follow-up fixes look good — no additional issues found in scope" |
The pre-existing key={ product.title } nit in renderProductPreview was left untouched (outside this feature's scope, keeping the diff minimal).
Unaddressed (flagged for owner): None.
CI: all required checks passing on 95f6fdf335. The non-required external "Test plugin upgrades" check at developer.jetpack.com is independent of this change.
Drop redundant package-name prefixes inside each package's own changelog (per the skill style guide § Prefixes and scope), tighten the search package's Added entries the reviewer flagged as non-imperative or too technical, split compound bullets, and regenerate the Jetpack readme: - charts, components, activity-log, forms, search (Fixed), jetpack plugin (Improved compatibility): drop the prefix that repeats the package name. - search Added: rephrase the REST entry to start with `Add` and drop the `Module_Control` aside; de-internalize the rebuild-mode entry (no `Custom_Taxonomy_Slot_Mapping::backfill()`); split the Results List auto-switch entry into the behavior bullet and the opt-out toggle bullet (#48943); capitalize Whitelist; drop the `Search:` prefix on the WP-CLI backfill entry; split the `Search: AI Answers` entry into two `AI Answers:` bullets — one for the streaming panel, one for the customization dashboard (#48592). - Regenerated `projects/plugins/jetpack/readme.txt` via `tools/plugin-changelog-to-readme.sh jetpack`.
…earches (#48943) * Search: auto-switch Results List to Product view for product-scoped searches When a search is scoped to exactly the product post type via the ?post_types[]=product URL parameter, the Results List block now renders in the Product layout automatically instead of the saved format. A new per-block autoProductView attribute (default on, WooCommerce-only inspector toggle) lets authors opt out. Gated behind the existing woocommerce_blocks_enabled() check so it never forces WC-shaped markup on a non-Woo site. * Address review: correct trigger-URL shape in help text/comments, document no-memo choice, expand changelog (comment #4483062776)
…earches (#48943) * Search: auto-switch Results List to Product view for product-scoped searches When a search is scoped to exactly the product post type via the ?post_types[]=product URL parameter, the Results List block now renders in the Product layout automatically instead of the saved format. A new per-block autoProductView attribute (default on, WooCommerce-only inspector toggle) lets authors opt out. Gated behind the existing woocommerce_blocks_enabled() check so it never forces WC-shaped markup on a non-Woo site. * Address review: correct trigger-URL shape in help text/comments, document no-memo choice, expand changelog (comment #4483062776)
Fixes SEARCH-201
Why
When a shopper follows a product-scoped search link (
?post_types[]=product), the Results List previously rendered in the saved editorial format — title, breadcrumb path, excerpt, author/date — which looks wrong for a store. It now automatically switches to the Product grid (image cards with price and rating) for product-only searches, so a shop search looks like a shop without the author having to hand-pick the layout. Authors who don't want this can turn it off per block.Proposed changes
autoProductViewattribute onjetpack-search/results-list(boolean, default on).render.phpauto-switches the resolved layout toproductwhen the request is scoped to exactly theproductpost type via the URL — gated byautoProductViewand the existingSearch_Blocks::woocommerce_blocks_enabled()check, with the non-Woo collapse still the final gate (never forces WC-shaped markup on a non-Woo site).Search_Blocks::request_is_product_only()helper — true only when the combined post-type request resolves to exactlyproduct(mixed requests keep the saved layout so non-product results never render as product cards).Scope note: the trigger is the Jetpack Search array shape
?post_types[]=product— the shapestore/url-state.jswrites and round-trips. The scalar?post_type=productis a WordPress core query var that reroutes the request to the WooCommerce shop archive before any Jetpack Search block renders, so it never reaches this block and is intentionally a non-goal (handling it would require overriding standard shop-archive routing site-wide).Screenshots
Same
?s=hat&post_types[]=productURL, captured at 1440×900 via local docker.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Requires a WooCommerce site with the Search 3.0 blocks experience and the WC search blocks enabled (
add_filter( 'jetpack_search_woocommerce_blocks_enabled', '__return_true', 20 )), with a Search Results template containing aresults-listblock whose saved format is not Product. Acceptance criteria:?s=<term>&post_types[]=productrenders the Results List as a product grid (image cards, price, rating) withautoProductViewon (default).?post_types[]=product&post_types[]=post(mixed) keeps the saved format.?post_types[]=product.?post_types[]=productnever produces the product layout (collapses to Expanded).jp test php packages/searchandjp test js packages/searchare green.