Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search Block: Apply border color correctly when button is outside or absent #47067

Merged
merged 1 commit into from
Jan 12, 2023

Conversation

t-hamano
Copy link
Contributor

What?

This PR fixes an issue where the border color is not applied correctly on the front end when there is a button outside or no button in the search block.

Editor Frontend
editor frontend

Why?

I think the condition for applying the border color class is reversed.

How?

I have correctly changed the condition statement. At the same time, I added an empty check for the $border_color_classes, as is done on the button element.

Testing Instructions

  • Use the following markup to add blocks.
Test Data
<!-- wp:search {"label":"The border color is applied to the input and button elements when the button is outside","placeholder":"Placeholder","buttonText":"Search","style":{"border":{"width":"10px"}},"borderColor":"pale-pink"} /-->

<!-- wp:search {"label":"Only the wrapper gets the color when the button is inside","placeholder":"Placeholder","buttonText":"Search","buttonPosition":"button-inside","style":{"border":{"width":"10px"}},"borderColor":"pale-pink"} /-->

<!-- wp:search {"label":"Only the input element gets the color when the block has no button","placeholder":"Placeholder","buttonText":"Search","buttonPosition":"no-button","style":{"border":{"width":"10px"}},"borderColor":"pale-pink"} /-->
  • As with the editor, verify that the border color is applied correctly on the front end.

'<input type="search" id="%s" class="wp-block-search__input %s" name="s" value="%s" placeholder="%s" %s required />',
'<input type="search" id="%s" class="%s" name="s" value="%s" placeholder="%s" %s required />',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor Fix: While I was working I noticed that the wp-block-search__input class is duplicated. This class is not needed here as it was added first.

@t-hamano t-hamano self-assigned this Jan 11, 2023
@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Block] Search Affects the Search Block - used to display a search field labels Jan 11, 2023
@t-hamano t-hamano marked this pull request as ready for review January 11, 2023 13:51
@t-hamano t-hamano requested a review from ajitbohra as a code owner January 11, 2023 13:51
@github-actions
Copy link

Flaky tests detected in 85bf0af.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3893420232
📝 Reported issues:

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching and fixing this @t-hamano 👍

I could replicate the original issue when using simple "flat" border colors. When configuring different individual borders they were applied correctly. After checking out this branch all border colors were consistent between the editor and the frontend.

Code changes LGTM!

Before After
Screenshot 2023-01-12 at 6 07 38 pm Screenshot 2023-01-12 at 6 16 38 pm

@t-hamano t-hamano merged commit 8698d84 into trunk Jan 12, 2023
@t-hamano t-hamano deleted the fix/search-border-color branch January 12, 2023 10:09
@github-actions github-actions bot added this to the Gutenberg 15.1 milestone Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Search Affects the Search Block - used to display a search field [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants