Search Block: Ensure color settings apply to input field when button is disabled#77219
Merged
mikachan merged 4 commits intoWordPress:trunkfrom Apr 10, 2026
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Contributor
Author
Contributor
Author
|
Thanks a lot @mikachan for quick response and testing. I appreciate it 🙌 |
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.


What?
Closes #62715
This PR updates the coloring logic for the Search block so that background and text colors correctly apply to the input field when the block is configured without a search button.
Why?
When a user changed the background or text color in the Search block, the styles only applied to the search button. If the user configured the block to hide the button (using the "no-button" state), the color settings had no visual effect because they were not cascaded down to the input field. This enhancement satisfies user expectations by ensuring custom colors gracefully fallback to styling the input field when the primary button component is absent.
How?
block.json): Updatedselectors.colorto target both the button (.wp-block-search__button) and the input field when the wrapper explicitly defines the no-button state (.wp-block-search.wp-block-search__no-button .wp-block-search__input).index.php): Added a conditional check ($use_input_for_colors) to determine if the block is configured asno-button. If so, inline color and background-color styles are redirected to$input_stylesinstead of$button_styles.index.php): Updated the rendering logic so that if the button is missing (! $show_button), the generated$color_classes(likehas-text-colorandhas-background) are correctly appended to the<input>element's class array.edit.js): Pushed downcolorProps.classNameandcolorProps.styledirectly intotextFieldClassesandtextFieldStylesdynamically whenhasNoButtonis true, ensuring 1:1 visual parity within the canvas editor when configured from Inspector Controls.Testing Instructions
core/searchblock to confirm thetheme.jsonengine routes the CSS accurately.Screenshots or screencast
Before the fix
search-block-before.mov
After the fix
search-block-no-button.mov
Use of AI Tools
Used AI assistance for logic evaluation for block state dependencies, and drafting PR text. All generated changes were reviewed and logically validated.