-
Notifications
You must be signed in to change notification settings - Fork 25.6k
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
Add search input title to resolve pa11y finding #2181
Conversation
@SeanKilleen https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/search I see name but I do not see title as a valid attribute of search input. |
I don't think this is needed. You don't need to add a title to a search input. Adding this would mean there would be an annoying unnecessary tooltip to users who don't use screen readers |
@inetbiz happy to consider other attributes besides title. If you refer to #2180, the failure message lists some options. Let me know if you have a preference. @coliff, I hear you on the use of The point of this PR is that I'm trying to improve the lighthouse score of my site and it's accessibility, so I'm using an automated tool called |
As stated by others, I don't think this is needed. Is it possible the pa11y tool you're using is detecting false positives? I've never used it personally. If you take the MM starter site which has site search enabled and run it through Google's Lighthouse auditing tool it doesn't mention any issues with the search Accessibility is scored a 81 and the issues it's flagged are for some ancillary text in the footer because it thinks the contrast ratio is too low. And a pagination link that is Both of these could likely be improved, but in the grand scheme of things they appear to be minor. |
Fair points all around. Let me do a little bit more research on this and come back. My understanding is it's tied to the WCAG 2.0 My understanding is that adding one of these attributes makes it easier for tools that use accessibility APIs, but I'll try to find the backing for it if folks aren't willing to consider this change or similar without it. I would also suggest that the contrasting colors on links is only minor if you don't have a disability that then prevents you from reading those links, which is important to me as someone who blogs. But that's easy enough to override so I'm not worried about it at a theme level. |
The correct way to make the search input more accessible would be to add a <label for="search">
<span class="sr-only">Search</span>
<input type="search" id="search" aria-placeholder="Enter your search term..." class="search-input" tabindex="-1" placeholder="Enter your search term...">
</label> The screen-reader only class is applied to the text so it's not shown on the front-end, but by using According to the W3 the proper way to label a control form is how I've done above, or if you don't want to use the They also mention adding a
|
I'm happy to apply that approach. Would you be ok if I modified the PR as such? (Edit: sorry, I misread your earlier post. I'll do some more research.) |
Fair point. I only mentioned it's minor because those links are minor and not something that is important for the main content. They're purposely low contrast to diminish their importance on the page e.g. footer copyright and other "byline" text. This is why I included the "high contrast" skin which pumps up the contrast on all elements. |
Oh nice! I wasn't aware of the high contrast skin; great tip. I'll look around a bit more and either close this or provide more info. |
another noteworthy tip is, I saw @mmistakes Lighthouse screenshots, and they were from an older version of Lighthouse. The Lighthouse test built-in to Devtools of shipping Chrome is always an older version. To get the latest version (5.1.0.1 at time of writing - which has new and improved audits - including fixes for accessibility audits) - use the version from the Chrome webstore. REF: https://github.com/GoogleChrome/lighthouse/blob/master/changelog.md Chrome Extension: https://chrome.google.com/webstore/detail/lighthouse/blipmdconlkpinefehnmjammfjpmpbjk |
@coliff great tip, thanks! Since I honestly don't have enough time to research this right now, I don't want to leave a PR hanging out here. Going to close this. Thanks for the feedback so far! If I find more information on the source, I'll update and address a little more effectively. |
This is a bug fix.
Summary
This adds a
title
attribute to the search bar for the sake of screen-readers, which will reduce an accessibility error that pa11y found (which I first saw on my personal blog).Context
Resolves #2180.