-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
Tooltip has some accessibility issues #219
Comments
Fair enough. Let's try to get them close then. 😄 I fixed a bug where
It seems as though pressing escape would be acceptable, as long as it doesn't result in focus being lost from the tooltip target, but I wanted to ask before making that change. Note that all the accessibility updates I made tonight are in Of course, there's still more to be done. 😅 |
the Escape key is the closest you'll get for something meant as a component for J Random Devs to use-- were you building your own app/website, you could try some of the suggestions in the video I pasted earlier (such as a dedicated close control inside the persisitent tip). The Escape key isn't terrible for general tooltips, but the moment your tooltip'd element is inside something already listening for then Escape key, keyboard users can no longer predict what will happen (will the tooltip simply vanish, or will the (example) modal dialog close on me?) and screen reader users who are fully blind can't see that there's a tooltip and may be expecting Escape to do something else. So, TL;DR Escape key listener is probably your best option for now. |
Hello, I've been trying the tooltip with NVDA screen reader (updated) and it still does not work for me, it only read the element content. |
I'm unfortunately not able to test on NVDA at the moment, so contributions are welcome to help make tooltips perform better with it. |
Hi, I can confirm the posted behaviour of NVDA not saying anything particularly special about the button (Tabbing to the button merely presents that it's a button and called "Hover Me"), and that one must move forward with their browsing caret to hear the tooltip as if it were normal content which happens to follow the button. That is, it sounds as if we have this HTML:
Just plain content which happens to be after the button, and no indication that it's intended to be an accessible description of the button itself. I see that currently we've got this resultant HTML inside a shadow DOM:
and a following sibling element (inside a nested shadow DOM) has this
I'm thinking the reason Normally we'd say, set I'm not sure what would make this work. There's also the possibility that The clickable example (second tooltip button) can also be confusing: it's basically using click to change states (showing and not-showing the tooltip). But then two questions come up:
|
Reopening for further evaluation. Thank you for the detailed info, @StommePoes! |
Sorry I can't give any useful kind of solution :( One idea is to rearrange the nested things so that the tooltip chunk and the button are inside a single shadow DOM and then the tooltip can easily aria-describe the button with Then with any screen reader what users should encounter is:
Those'll all read out together in whichever order the particular screenreader does or however the user may have configured it. A user browsing (just reading content and not focussing on anything) with a screenreader that uses modes may only get the Hover Me name and that it's a button but I think it differs between SRs whether other control semantics get offered if the user isn't in a "focus" mode... I can't remember anymore, my brain has become cheese with those carbon-dioxide-gas holes, lol. So anyway any testing is only:
and not worry about what's announced if users are just reading stuff. |
@StommePoes @claviska I just came across this thread because I noticed the tooltips are still not reading the content (I'm using VoiceOver), and I have a suggestion that may be helpful. I recently worked on a project where we came up against the shadow DOM interfering with accessibility, specifically, with ARIA labelling attributes not finding their mates because they exist in different DOMs. As @StommePoes mentioned, one fix is to have the button and content exist in the same shadow DOM, which has its own challenges (thinking of styling in particular). That didn't work for our implementation because we wanted to let users pass in whatever trigger element worked for them (button, inline link, some text), while retaining control over the content rendering. So, we turned the content block into an aria-live region and populated it on hover/focus. This feels like a cheat, but it actually worked really well, and with the added bonus that we could configure it to read the tooltip content once or every time it's shown. |
This was exactly the problem. I want to be able to wrap the trigger with a tooltip element so they can use whatever trigger they want.
This is a brilliant suggestion! I just tried it and it's reading well now on hover and focus. You can try it out here: https://next.shoelace.style/components/tooltip I realize tooltips aren't the easiest to get right in terms of accessibility, but hopefully this improvement makes them more useful for everyone. Since this thread is getting long and I believe the main issues have been resolved, I'd like to close this thread and identify any new issues or suggestions in a new one. Thanks for the detailed feedback, @StommePoes. And thanks for the great |
The tooltip component has some accessibility issues. I thought it was easier to lump them all together for the single component rather than separate issues for each.
I threw together a test page https://stommepoes.nl/work/shoelace/shoelace_demo.html and, on Windows only, ran 2 screen readers (NVDA latest, JAWS 2019) and two screen magnifiers (Windows Screen Mag, ZoomText) on 3 browsers (Edge latest, Chrome latest, Firefox latest... as of 23 September 2020). I don't own any iThings or I would have run VoiceOver on Safari (this is the combination for MacOS that is preferred for testing) as well.
See the notes below: tooltips are difficult components to actually make accessible. The best you can do is just get close to the current recommendations :(
The tooltips:
To Reproduce
Steps to reproduce the behavior 1:
Steps to reproduce the behavior 2:
Steps to reproduce behaviour 3:
** Focus moving to a select was rather intermitant. Most of the time focus moved to the select directly above the "Hover me" button on my test page. Once I had Chrome always setting it on the first select set near the top of the page. Once in Firefox, focus did not move and the page acted like the demo test page—until I chose an option in that select, then Tabbed to the "Hover me" button. Then focus was placed on that select.
Expected behavior
Accessible descriptions (such as text linked to a control using
aria-describedby
) are announced when the controls receive focus.Tooltips are hoverable, persistent and dismissable (as per https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus)
Screenshots

Desktop:
Notes: tooltips are a poor UX pattern. This is an example where any fixes you do are solely to get your component closer to checking boxes on some "accessibility list", because they cannot truly be fixed.
For the "tooltip not read as an accessible description" (which, I am personally against throwing tooltip text at people simply because they focussed on a control which keyboard-only users cannot help, while sighted mouse users get to choose whether they want to view that tooltip text), I believe the reason it's not reading out is because the tooltip has
aria-hidden="true"
on it until the control is focussed, and I believe the removal of thearia-hidden
state happens AFTER the browser has communicated to the assistive technology/screen reader that the acc. description does not exist. So it seems the only solution when following the recommendedaria-describedby
pattern is to leave the tooltip exposed (and simply visually hidden). To be honest, I feel it's more user-friendly that the text comes afterwards, but then completely blind users may not know that the tooltip text is being offered as a "tip" in the context of the control rather than just plain text. Also, I dunno what Macs do.For the "hoverable, dismissable" parts: this is because when using screen magnification, tooltips have 2 problems: either they pop up unwanted and cover screen content and I may want to be able to see the screen without moving my viewport (moving the mouse is how one moves the viewport, if you can use a mouse), but conversely if I want to READ the tooltip, I need to be able to move my mouse over the tooltip, since the tooltip may be too big to fit in my viewport when I'm hovering the button.
These two things are fixable (the latter with CSS alone even), but the current suggestion on the WCAG is to offer the Escape key to close tooltips, because the Escape key is the typical pattern of removing stuff that has popped up or open.
However, this can get in the way of screen reader users who are unaware there is a tooltip, and can conflict if the tooltip'd element is inside a component which is already listening to the Escape key (such as a modal dialog).
Watch this and cry with me: https://www.youtube.com/watch?v=7s_sjl4bEP8
I'm making this ticket simply because I think you should be aware of the current issues and making the tooltips themselves hoverable is a doable fix for at least one of these issues. There might be a known way to deal with the accessible-description part somewhere on the web, but since I hate tooltips for the reasons listed above, I didn't look. Paul J Adam has created several examples in the past.
The text was updated successfully, but these errors were encountered: