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

Treeview images need to be hidden from screen readers #1768

Closed
carmacleod opened this issue Feb 18, 2021 · 3 comments
Closed

Treeview images need to be hidden from screen readers #1768

carmacleod opened this issue Feb 18, 2021 · 3 comments
Labels
bug Code defects; not for inaccurate prose Example Page Related to a page containing an example implementation of a pattern

Comments

@carmacleod
Copy link
Contributor

The Open/Closed Folder and File icons in the File Directory Treeview examples are added using CSS ::before content image urls.

The problem with this is that screen readers announce the image in virtual cursor mode, and since it doesn't have alt text, it's just announced as "image". This becomes even more of a problem in touch interfaces because the image is an extra "swipe stop" (if that's what it's called), so the user has to swipe twice as often as necessary to go through items in the tree.

In an ideal world, we would be able to simply add empty alt text to the CSS content image using / "", like so:

[role="treeitem"][aria-expanded="false"] > span::before {
    content: url(../images/closed.png) / "";
}

[role="treeitem"][aria-expanded="true"] > span::before {
    content: url(../images/open.png) / "";
}

[role="treeitem"].doc::before {
    content: url(../images/file.png) / "";
}

However, Firefox and Safari do not yet support this CSS feature. See Alternative Text for CSS Generated Content.

So I think for now we need to use <img alt=""> instead of CSS content images. I guess we'd have to swap out the Open/Closed Folder image with javascript (but this treeview needs javascript anyhow, so that's ok). The code might not be as cool, but it will work better with screen readers, including mobile/touch-based screen readers.

@nschonni
Copy link
Contributor

Is SVG better for codepen compatibility, or is that not an issue for this one?

@carmacleod
Copy link
Contributor Author

Good point, @nschonni. Also, SVG with currentcolor would be better for Windows HCM - I haven't tested, but I'm guessing that those black icons disappear completely on black background. :)
So instead of using img with empty alt text, we should use <svg aria-hidden="true">.

@mcking65 mcking65 added bug Code defects; not for inaccurate prose Example Page Related to a page containing an example implementation of a pattern labels Feb 22, 2021
@mcking65
Copy link
Contributor

This has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Code defects; not for inaccurate prose Example Page Related to a page containing an example implementation of a pattern
Development

No branches or pull requests

3 participants