-
Notifications
You must be signed in to change notification settings - Fork 297
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 our own VisuallyHidden component to use for screen-reader text #2165
Comments
@tofumatt if we aren't going to use the component from Gutenberg, why not use Aside from that, it doesn't rely on a specific class name which I think makes more sense in our case since the component may be used on both front (at least admin bar) and backend. Is there a better reason to create our own here over an existing option? Edit it's also worth linking the Gutenberg PR where their component was introduced here as there is quite a bit of conversation there which may be useful to consider. |
No major opposition from me to using Reach, but our (current) needs are quite spartan and our component, as proposed, would be lighter-weight than theirs. They use the As mentioned: we need to use raw spans inside i18n strings (which we do have to do in several places), so having our I'm usually for adding dependencies to reduce our maintenance burden, especially for a11y concerns where we might miss things, but in this case I think a home-grown solution is better. |
I agree that the inline style is less efficient, but it's also "batteries included" 😄 Regarding the use in translatable strings, I don't think we should "mirror" the HTML of any components in these strings, but we didn't really have much options in the past. Now we have We're already using it in a few places now: site-kit-wp/assets/js/components/settings/module-setup-incomplete.js Lines 44 to 59 in 6a69f0d
Which ever component we use I think part of this issue should be going through and updating the existing screen reader text bits to use the real component, using I could go either way on which component we use; both have their pros and cons. I think the more valuable piece of this issue is to use a dedicated component instead, and use it everywhere it's needed 🙂 I still kind of think the Reach component is nice since it isn't that much added markup and should be up-to-date with accessibility best practices, but I'm open to keeping it closer to what we have now if preferred. Thoughts @felixarntz ? |
Yeah, our existing Using |
@aaemnnosttv @tofumatt I think coding our own simple Regarding the use of |
I find "Visually hidden" to be a better description of what we're doing—the aim is to have that text there semantically, it's for more than just screen readers. Plus: WP itself uses I've created a new issue for the |
I agree with @tofumatt – FWIW, the component introduced in Gutenberg was originally Since we're not publishing the component for use outside of WP, I think it's okay to rely on that class for our needs, although if we ever decide to change it, that would really be an implementation detail and the usage wouldn't need to change. @tofumatt as silly as it sounds, we should probably introduce a story for this component. We probably don't need additional VRT for it, since many other scenarios will use components that have it, but it might not be a bad idea to add a VRT test for this component specifically. What do you think? |
Adding a Storybook component makes sense, and even a VRT. Especially since we're relying on a third-party (WordPress) style to provide this class, we should make sure it's always hidden 😄 I've added it to the IB 👍🏻 |
IB ✅ |
QA ✅ |
Feature Description
Currently we use
<span className="screen-reader-text">
across our codebase to visually hide screen-reader text in the app. This is a fine approach, but as pointed out in the IB for #2093, it'd be nice to have a dedicated and more-descriptiveVisuallyHidden
component we can use to put screen-reader text inside without having to memorise CSS class names, etc.It was suggested we use Gutenberg's
VisuallyHidden
component, but asURL_FORTHCOMING
shows, its defaults don't suit us. It'd be better to create our own, simple,VisuallyHidden
component that looks like this:Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
VisuallyHidden
component should be made available to developers for screen-reader text.<span className="screen-reader-text">
instances should be replaced with<VisuallyHidden>
.Implementation Brief
VisuallyHidden
component (as outlined above) inassets/js/components/VisuallyHidden.js
<span className="screen-reader-text">
with the new<VisuallyHidden>
component.Note that instances of
<span class="screen-reader-text">
will be able to be removed; there are instances of using the<span>
tags directly inside translation strings (egsite-kit-wp/assets/js/components/setup/compatibility-checks.js
Lines 123 to 149 in d194354
stories/visually-hidden.stories.js
understoriesOf( 'Global', module ).add( 'Visually hidden', () => {} );
that includes the VisuallyHidden component.Test Coverage
Visual Regression Changes
QA Brief
Changelog entry
VisuallyHidden
component.The text was updated successfully, but these errors were encountered: