-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Twoslash output is inaccessible #32
Comments
I am not very familiar with a11y myself - I wonder what would be your solutions in mind? From my personal point of view, tooltips from Twoslash are usually "additional information" but not the main content, which serves as "good to have" but also okay to go without. I imagine myself as a keyboard user or screen reader; I would not want my focus or reader to be "trapped" inside the tons of type information when reading a code snippet. For example, something like: const a = Math.min(1, 2) It can be read as const a | const a: number | = Math | var Math: Math | An intrinsic object that provides basic mathematics functionality and constants. | (method) Math.min(...values: number[]): number | @param values — Numeric expressions to be evaluated. | (1, 2) If we make tooltips "accessible" (I use In a way, I consider the experience much worse. I would rather hide some "secondary, optional information" instead of having a bad UX. I can be very biased. So I'd love to hear what you suggest we improve. |
Thank you for the reply @antfu!
I think the same concerns about not overwhelming the user apply for all interaction types, so I think this is a bit separate from whether or not to expose the tooltips at all. TwoSlash should ideally be applied thoughtfully as an intentional enhancement of specific relevant terms (rather than applied everywhere), but then its content should still be available to all users. If designed well, accessible tooltips would not “trap” users, but allow them to skip over or dismiss them easily just like a mouse pointer user can. If there is a concern that there are too many tabs required to move through a code sample, one option would be a “skip” link at the start of the code snippet tab order that allows a keyboard user to jump to the end of the block.
It should be possible to have a screenreader read the text as it does currently but also then read tooltip information on focus. That would avoid breaking up the flow as your example does. In other words, instead of imagining the content + tooltips as a linear stream of
Given there are two major areas of WCAG in my post above, I think there are also at least two chunks of work/focus.
|
(Reposted from shikijs/twoslash#195)
Hey there 👋 I noticed that currently TwoSlash produces inaccessible output.
This issue is not a comprehensive accessibility audit, but I wanted to draw attention to some key issues that would need addressing to make TwoSlash code blocks usable by more users.
The references here are to Web Content Accessibility Guidelines (WCAG) 2.2
Key accessibility failures
Guideline 2.1 Keyboard Accessible
Twoslash tooltips are only available via mouse/pointer hover, so fails most of WCAG Guideline 2.1 regarding keyboard accessibility: it should be possible for users to access the content of tooltips using only the keyboard.
Guideline 4.1 Compatible
Twoslash tooltips are not available to screen readers: navigating a code sample using Twoslash, there is no way for screenreaders to access the content of tooltips.
Other details
There are some smaller things like the following, but these are kind of moot given the bigger issues:
1.4.13 Content on Hover or Focus
Tooltip content is not dismissible via a mechanism other than moving the pointer’s hover position.
The text was updated successfully, but these errors were encountered: