-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
create a screen-reader-text label for search block (fix #17351) #17983
Conversation
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.
Hi @skorasaurus, thank you for your contribution 👍 The PR seems to be in the right direction. There is only one thing I think we should address before the merge, currently, we are using a static label "Search" and I think this label needs to be translatable using __(...)
would that look like the following:?
|
note to self to rebase and rename class to VisuallyHidden - ref #18167 |
It looks like this PR will fix #17535 |
@gziolo It is intended to fix #17351 . I have already rebased this morning; did I not do it correctly? I haven't changed the screen-reader-text to the VisuallyHidden component just yet; as the introduction of the component is a little confusing for me (I'm also very new with React) and I'm trying to figure out how to correctly apply this.... In my naive opinion, since this block seems to me written more in php rather than in JS (compared to other blocks), should I just swap out the with screen-reader-text class with the components-visually-hidden class or should I do something else? |
You should see only your commits on this branch. There are over 130 commits at the moment from various contributors. You can also try to recreate this branch from scratch if that makes it easier. |
I can give you a correct answer once this branch is cleaned up, otherwise, I will have to guess. In PHP you can use |
@gziolo, I rebased it and only my commit is now showing in the PR although I am unsure if I did properly (I followed directions from https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request#perform-a-rebase). I'm still using the screen-reader-text class since I haven't figured out how to replace it with the VisuallyHidden component. |
You can't replace it in PHP code. It's fine as is. There are 3 issues reported by PHP linter which needs to be addressed before this PR can be landed:
It needs to be tested. The code itself looks good. Good job! 💯 |
… by default fix php spacing in block file
I'm running ubuntu 18.04 and have been doing my development with vvv. I ran I fixed the spacing issues and tab issues that you mention in a squashed commit . But there is one more error that remains: Although I did not touch that, does that need to be fixed? Lastly, |
Travis is green so it looks like you were using more strict rules for linting PHP code. This is what is executed for PHP code: Line 144 in 17a6ab0
In other words, this PR seems to be good to go. |
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.
Nice work, I can confirm it works as expected when no label is provided 👍
Thank you for the assistance. |
Description
The search block should always have a label in it even if it's not visible.
When a user removes the label from the search block when the user is editing content; there should be still be a label present for the corresponding input field, so a user who is consuming the site with a screen reader or other assistive technology has a contextual clue of what the empty input field is :)
What this addition does is, when the label is deleted, a label named "search" is created but is not visually displayed on the screen because the screen-reader-text class is applied to the label element.
I've also manually tested this when you insert multiple search blocks into the same post; a unique label property is created for each one.
WordPress' Accessibility Labeling guidelines also state that all future code should have a label as well.
How has this been tested?
As mentioned at #17351 ; I've tested this in JAWS 2018 with default settings and chrome; and it functioned as I expected.
If you'd like to personally test yourself:
( pull in my changes )
(Note: I haven't ran automatic tests on this yet, note to self, I'll do that https://github.com/WordPress/gutenberg/blob/master/docs/contributors/testing-overview.md#php-testing )
It's also my first feature/bug PR on Gutenberg. :)
Checklist: