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 should always have a label even if its not visible #17351

Closed
skorasaurus opened this issue Sep 5, 2019 · 5 comments
Closed

Search Block should always have a label even if its not visible #17351

skorasaurus opened this issue Sep 5, 2019 · 5 comments
Labels
[Block] Search Affects the Search Block - used to display a search field [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended

Comments

@skorasaurus
Copy link
Member

skorasaurus commented Sep 5, 2019

Describe the bug

The search block should always have a label in it even if it's not visible.

To reproduce
Steps to reproduce the behavior:

  1. Create a new page or post
  2. add search block
  3. delete the search label
  4. publish post/page

Expected behavior
Even if a label is removed (we should generally discourage it, imho); there should be a default field so a user who is consuming the site wit ha screen reader or other assistive technology has a contextual clue of what the empty input field is :)

WordPress' Accessibility Labeling guidelines also state that all future code should have a label as well.

This bug was initially addressed by @afercia at #16189 (comment)

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):
all

Smartphone (please complete the following information):
all

Additional context
This issue is still applicable even when #17343 (as of 4454bff) is applied to the code.

@talldan talldan added [Block] Search Affects the Search Block - used to display a search field [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). labels Sep 5, 2019
@afercia afercia added [Type] Bug An existing feature does not function as intended [Priority] High Used to indicate top priority items that need quick attention labels Sep 6, 2019
@afercia
Copy link
Contributor

afercia commented Sep 6, 2019

Thanks @skorasaurus for your report!

I see the accessibility feedback given on #16189 (comment) hasn't been addressed yet and that PR was merged anyways. I'd kindly argue that's not the best way to improve collaboration between teams.

Regardless, all the points from the comment on #16189 still apply: WordPress aims to produce valid, semantic, as accessible as possible, markup.

The absence of a properly associated <label> element for the search field is actually a regression compared to core functions like get_search_form(), which makes sure there's always a label.

@skorasaurus
Copy link
Member Author

skorasaurus commented Sep 8, 2019

I did an initial proof of concept at skorasaurus@f5c39fa that creates a label element of 'search' that's hidden with screen-reader-text if the label is initially removed by the user in the block editor. It's valid html but I don't have access to a screen reader at this moment (I do on weekdays) to determine if it would work as I expect.

@skorasaurus
Copy link
Member Author

skorasaurus commented Sep 30, 2019

I've tested this on a screen reader (JAWS 2018; chrome 72.0.3626.121) and it is working as I expected:

What happens:
When a user focuses onto a search input field, even when no label is present, it will say
"search, edit, type in text"
I also tested in IE 11, and when no label is present, it will say "region search, edit, type in text".

If you want to change the default label - I made it to be "Search" - to something else, I'm ok with it.

I would appreciate it someone else were to test this and to make sure that my code matches the WP Guidelines.

To test:

    • Create a new post
  1. Add a search block
  2. delete the label text above the search input field;
  3. publish post.

(if there's an automated way to do this, that'd be super)

@epiqueras
Copy link
Contributor

@skorasaurus Thanks for working on this!

Open a PR with your changes so that we can get them merged 😄

@skorasaurus
Copy link
Member Author

closed in #17983 and merged \o/

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 [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants