Search block : Match behaviour of global styling for border and color with local styling (inspector controls) to remove inconsistency#77060
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. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @dpmehta! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
There was a problem hiding this comment.
Thanks for working on this 🙌
I've tested this with a couple of themes, and it tests as expected with the default Search block:
With Twenty Twenty-Three:
| trunk | This PR |
|---|---|
![]() |
![]() |
With Ollie (theme overrides the input border):
| trunk | This PR |
|---|---|
![]() |
![]() |
However, it doesn't look like this PR addresses the issue described in #62715, as the styles are not applied to the input in the "No button" setting:
Should this PR also apply these styles to the input?
|
Thank you so much @mikachan for confirmation , i just wanted to ask how can i merge this PR because currently it is showing merging is blocked though changes are approved. It would be great if you can help me out with this. |
|
I've merged it for you! I think the task that updates the Props comment was getting stuck, but I think it's already up to date, so it doesn't matter 😄 |
|
Thanks a lot ! 😄 @mikachan for guidance and help ! |




What?
Closes #42339
This PR ensures that Global Styles for border and color properties are correctly mapped to the Search block's internal sub-elements (input and button) instead of the outer container.
Why?
The Search block uses
__experimentalSkipSerializationto handle its complex layout. However, this caused Global Styles (applied via the Styles panel) to target the root block container by default. This created a discrepancy with local Inspector Controls, which target the input and button. Users expected global styling to match the visual outcome of local styling.Furthermore, we identified a specificity conflict where hardcoded CSS in a theme's
theme.json(like Twenty Twenty-Five) could override these Global Styles because both are wrapped in:root :where()and the theme's custom CSS was winning via cascade order.How?
packages/block-library/src/search/block.jsonto add explicitselectorsmapping forborderandcolor.borderselector now targets specific internal elements (.wp-block-search__content,.wp-block-search__input, and.wp-block-search__button) depending on the block configuration.colorselector was updated to target the.wp-block-search__buttonensuring that global background and text color settings apply to the button as they do in local settings..wp-block-searchclass in these selectors.Screenshots or screencast
Before ( Border issue )
After ( Border issue )
Before ( Color issue )
After ( Color issue )
Below testing is done
Tested all four button position modes (button outside, inside, no button, icon-only) with both global and local styles to confirm they match.
Checked that resetting global styles properly clears the border/color from those inner elements.
Verified there are no specificity conflicts where global selectors now override local ones unexpectedly (since these selectors are quite specific).
Testing Instructions
Use of AI Tools
Used AI assistance (Gemini 3.1 Pro) for code analysis, specificity debugging, and drafting PR text. All logic changes were manually reviewed and validated in a local environment.