Name the inherited query's search field s - #60
Open
roborourke wants to merge 4 commits into
Open
Conversation
An inherited query is the main query, and WordPress resolves that from its own `s`: a term only reaches the search results template because `s` is what routing reads. The field was named `query-s` there, so on arrival it rendered blank rather than showing the term being searched, and clearing it deleted a parameter the URL never carried — the "new" URL matched the current one, the router had nothing to fetch, and the results never changed. Name it `s` for the inherited case. `query-s` is still transposed onto the main query, so anything already linking to it keeps working. The test harness rewrites the theme's search template to put a search block inside the inheriting query loop, which is the one arrangement where these blocks see an inherited query and no bundled theme ships it. Fixes #50 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lj871x28S1DXjoVm7AB4k5
Playwright — PHP 8.3 / WP latestDetails
|
roborourke
marked this pull request as ready for review
September 2, 2026 11:39
…-fixes-07a61k-issue-50 # Conflicts: # inc/namespace.php
…-fixes-07a61k-issue-50
…-fixes-07a61k-issue-50 # Conflicts: # tests/e2e/README.md # tests/mu-plugins/register-test-content.php
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.
Fixes #50.
Reproduced
With a
core/searchblock inside acore/querythat inherits, on the search results template, arriving at/?s=Alpha:The field renders blank although the page is showing results for "Alpha", and clearing it deletes
query-s— a parameter the URL never carried — so the "new" URL equals the current one,actions.navigate()has nothing to fetch, and the results never change. Typing a term produces?s=Alpha&query-s=Beta, where the title still reads "Search results for: Alpha". Verified on WordPress 6.8.8 and 7.0.4.Changes
inc/namespace.php:render_block_search()names the fieldswhen the query inherits, which is the first option the issue suggests and whatupdateURL()'s existingname === 's'case already assumes. Prefilling then works through the samesanitize_search_query_var()call, andis_search()is true atpre_get_poststime, so thepost_type => anydefault for a search applies as intended.query-sis still transposed onto the main query, so existing links to it keep working.tests/mu-plugins/register-test-content.phprewrites the theme's search results template to place a search block inside its inheriting query loop. No bundled theme ships that arrangement, and it is the only one in which these blocks see an inherited query.tests/e2e/inherited-search.spec.jsasserts the field is namedsand prefilled from the site's term, and that clearing it navigates and widens the results.Verification
Both new specs fail on
main— the field reportsname="query-s", and the clearing test times out waiting for a navigation that never happens — and pass with the fix. Full suite: 22 passed on WP 6.8.8 and 7.0.4.composer phpcsandlint-jsclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01Lj871x28S1DXjoVm7AB4k5
Generated by Claude Code