Improve accessibility

Created on 16 June 2021, over 3 years ago
Updated 11 September 2024, 2 months ago

Problem/Motivation

There are two known accessibility issues. They're related to one another, so I've created a single issue.

  1. Keyboard navigation - When a user tabs through a page, the tooltip cannot be tabbed to.
  2. Screen reader - When using a screen reader, the tool tip definition is read first, followed by the glossary term. This is a confusing reading experience.
  3. Screen reader - There is no option to skip the definition, it is always read aloud. Ideally, the option to read the definition is given.

Steps to reproduce

  1. Tab through a page with a glossary term using the keyboard. Read a page with a tool tip definition with VoiceOver in Chrome.
  2. Read aloud a page with a glossary term using VoiceOver in Chrome.

Proposed resolution

  1. Code tooltip to be tabbable
  2. Ideal Solution: Code the definition in a manner recognizable to screen readers so that a user can chose whether to read the definition aloud.

    Less Ideal Solution: Code the definition so that it is skipped by screen readers. If the Glossify setting is set to show the tooltip and link the term to a definition page there is at least a way for a user to get to the definition.

Further Reading: Tooltips Accessibility Best Practices (including example code)

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States cedewey Denver, CO

Live updates comments and jobs are added and updated live.
  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States kreynen

    Somehow this got overlooked from 1.x->2x->3.0.0.

    Testing to see if this change can be made in https://git.drupalcode.org/project/glossify/-/blob/3.x/templates/glossif...

  • πŸ‡ΊπŸ‡ΈUnited States kreynen

    The link example in https://dequeuniversity.com/library/aria/tooltip looks like it would be easy to implement in https://git.drupalcode.org/project/glossify/-/blob/3.x/templates/glossif...

    The use of a tooltip role in https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/to... looked promising, but then https://sarahmhigley.com/writing/tooltips-in-wcag-21/ says "While it's not a bad idea to add it to the tooltip element, it doesn't seem to do much good either. The tooltip role does not appear to affect screen reader announcements in any meaningful way".

    At this point, I'm not sure what the right way to fix this is, but I'm also noticing that the tool-tip only link doesn't work in mobile. Clicking on the underlined term just selects it.

  • First commit to issue fork.
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Thank you very much for the implementation, folks!

    Now I'm wondering if we should really solve that on our own or better use a more accessibiliy friendly tooltip library? What do you think and is one out there?

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Would this improve the situation maybe? ✨ Support tippy.js by submodule Active

  • πŸ‡ΊπŸ‡ΈUnited States inregards2pluto Michigan

    I started a fork where I was creating a custom implementation, but I had to step away before fully completing it. Between then and now, my thinking has evolved and I agree it makes probably makes more sense to leverage an existing library.

    When I was previously working on this for a government client, we ended up using the USWDS tooltip component within our styleguide to meet WCAG 2.2 criteria. It was pretty straightforward to add the necessary class to the `glossify-tooltip` twig template and have it work as expected:

    {#
    /**
     * @file
     * Markup for inline tooltips.
     *
     * Available variables:
     * - word: the text where the tooltips applies to.
     * - tip: the tooltip text.
     * - tip_raw: the tooltip text in its raw format.
     * - langcode: the tooltip language code.
     *
     * @ingroup themeable
     * @see src/07-utility/_glossify.scss
     */
    #}
    <span tabindex="0" {% if tip %} title="{{ tip }}" {% endif %} class="glossify-tooltip-tip usa-tooltip" data-position="top" {% if langcode %} lang="{{ langcode }}" {% endif %}>{{ word }}</span>

    But I'm not sure how easily the one component can be pulled in separate from the full USWDS library, which would be a lot for a contrib module.

    I haven't used the tippy.js library before, but do we know how it reads with VoiceOver? When we were testing the USWDS component in conjunction with the tooltip component, we went through a LOT of iteration to make it useful to a screenreader user.

    On a separate note, another thing we ended up creating (which I'm hoping to recontrib back here) is a custom block that gathers up all the Glossified terms on a page and added them to a "Glossary" block at the bottom of the page. This is another technique that WCAG indicates improves accessibility, so maybe between that and the updated tooltip implementation, that should go a long way to improve the accessibility.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Thanks @inregards2pluto!

    Feel free to create a MR with the changes proposed!
    Regarding tippy.js / floating-ui it would be great if these libraries could be checked for accessibility, as they are very widely used, with huge impact. I'm not sure which one is enough for our needs and it seems tippy.js is built on top?

    Regarding the block: This should be a submodule then. Feel free to also provide a MR for that.

  • πŸ‡ΊπŸ‡ΈUnited States inregards2pluto Michigan

    Let me update my branch to use the tippy.js library and I'll do some testing. I'll report back in a bit :)

  • Pipeline finished with Success
    4 months ago
    Total: 140s
    #238536
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Please mind ✨ Support tippy.js by submodule Active . Separate approaches in separate branches are also fine!

  • πŸ‡¦πŸ‡ΉAustria tgoeg

    Chiming in, as an accessibility check of one site showed that glossified links should have an "aria-label attribute set that shows the purpose of the link", so something like "Glossary definition for " I guess.
    This string should be customizable and translatable, as implementations might differ. Some might call it glossary, some dictionary, other lexicon, etc.

Production build 0.71.5 2024