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: switch interactivity to the Interactivity API #53343
Search block: switch interactivity to the Interactivity API #53343
Conversation
Size Change: +8.4 kB (+1%) Total Size: 1.52 MB
ℹ️ View Unchanged
|
We now use WP Store to handle ARIA labels for button functionality, doing away with hard-coding labels. The labels now adjust based on the state of the search field, providing more explicit instructions for users. Co-authored-by: David Arenas <david.arenas@automattic.com>
As mentioned in #53292 (comment):
@DAreRodz and I implemented this for the |
I made some commits to support what I shared in this comment: link. I still have to review it properly, but it seems to be working fine, now. I want to:
|
Regarding this, it seems that, as the I added |
Flaky tests detected in 72426b0. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6074323676
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Tested it and works great 👍
'ariaLabel' => 'true' === $open_by_default ? $aria_label_expanded : $aria_label_collapsed, | ||
'ariaControls' => 'true' === $open_by_default ? null : $input_id, | ||
'type' => 'true' === $open_by_default ? 'submit' : 'button', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing's not clear to me:
If $open_by_default
is hardcoded to be false
on this line and never changed as far as I can see, then why do we still need those conditionals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added those conditionals so they follow the same logic we have in the client. I thought that this way, if for any reason we decide to change the $open_by_default
in some scenarios, it is clear which attributes would be affected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, got it. For me, it was slightly confusing because the existence of the $open_by_default
variable implies that there are cases when it's not open by default. Just a comment above this line mentioning that, for now, open_by_default
is a constant should be enough to clarify that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added a comment to reflect that 🙂
I've updated a bit the code so I'd appreciate a new review and (potentially) an approval. cc: @luisherranz @DAreRodz This pull request not only moves the Search block to use the Interactivity API but also solves a bug with the current implementation: Search.block.bug.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything works as expected and the code is clean and easy to follow. Great work! 🙂
I've added a couple of minor comments below.
A note about accessibility: we have copied the previous accessibility implementation, so everything should keep working as it was and I don't think we need to bother contributors to check again what we already checked. But if anyone finds any accessibility issue in the future in this block and finds this PR, please open a new issue and ping any of us, and we will fix it. Thanks!
Co-authored-by: Luis Herranz <luisherranz@gmail.com>
Co-authored-by: Luis Herranz <luisherranz@gmail.com>
What?
Fixes #53292
Why?
To add consistency to all Core blocks that needs frontend interactivity.
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast