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: Add space between attributes #61399

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

sabernhardt
Copy link
Contributor

What?

Attributes in the expandable Search block start tag need to be separated.

Why?

Without spaces, the HTML does not pass validation.

How?

In addition to spaces, this includes line breaks around $form_context so the attributes are indented the same.

Screenshots or screencast

Invalid output in WordPress 6.5 (no plugins):
Firefox flags the invalid HTML

<div class="wp-block-group is-content-justification-left is-layout-flex wp-container-core-group-is-layout-3 wp-block-group-is-layout-flex"><form role="search" method="get" action="http://localhost/wp65/" class="wp-block-search__button-only wp-block-search__searchfield-hidden wp-block-search__text-button wp-block-search" 
		 data-wp-interactive="core/search"data-wp-context='{"isSearchInputVisible":false,"inputId":"wp-block-search__input-1","ariaLabelExpanded":"Submit Search","ariaLabelCollapsed":"Expand search field"}'data-wp-class--wp-block-search__searchfield-hidden="!context.isSearchInputVisible"
		 data-wp-on--keydown="actions.handleSearchKeydown"
		 data-wp-on--focusout="actions.handleSearchFocusout"
		>

Copy link

github-actions bot commented May 6, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: sabernhardt <sabernhardt@git.wordpress.org>
Co-authored-by: carolinan <poena@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@sabernhardt
Copy link
Contributor Author

Related: #58943

@skorasaurus skorasaurus added the [Block] Search Affects the Search Block - used to display a search field label May 7, 2024
@carolinan carolinan added the [Type] Bug An existing feature does not function as intended label May 8, 2024
@carolinan
Copy link
Contributor

Hi
Can you include testing instructions for this PR? The code change looks valid to me, but I could not figure out where this markup is used.
I added the search block to a post, but it does not have these data attributes.

@sabernhardt
Copy link
Contributor Author

sabernhardt commented May 8, 2024

Thanks for adding the labels.

Steps:

  1. Open the editor (either site or post).
  2. Add a Search block.
  3. Choose the "Button only" option from the block toolbar.
  4. Save changes.
  5. View the post or site template on the front end, and view source to find the missing spaces.
  6. Apply the PR changes.
  7. Refresh the page and view source to verify that data-wp- attributes have space between them.
  8. Verify that the Search block still functions the same way (expanding the input and submitting search query).

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.

None yet

3 participants