Fix accessibility issues in form

Created on 25 September 2024, 3 months ago

Problem/Motivation

Entering office hours gives screenreader users a hard time. Let's pick at least the low-hanging fruit.

  • The all-day checkbox is too verbose (visually hidden label reads "Indicates if the entity is opened all day")
  • The time fields are too verbose (and contain more attributes than necessary)
  • First column in table is no heading, thus will not be announced (instead of "Monday" it reads "second row")
  • Action links have an empty href attribute, no aria attributes and provide no feedback (semantically should be buttons)
  • "From - to" range translates inappropriately generic to other languages

Steps to reproduce

I am focusing on the widget Office hours (week) with exceptions and seasons here.

  1. Add an office hours field to any node bundle
  2. Configure Time element type: HTML5 time input
  3. Configure Time notation: 24 hours
  4. Enable "Allow 'all day' situations
  5. Enable "Allow exception days
  6. Enable "Allow seasons
  7. In form display, choose "Office hours (week) with exceptions and seasons" widget

View mode with different configurations seemed good to me, skipping for now.

Proposed resolution

Low-hanging

  • All-day checkbox label: change "Indicates if the entity is opened all day" to "Open all day"
  • Change HTML5 time field markup (see below)
  • First column in table body: change <td> ... </td> to <th> ... </th>
  • Add a time span-related context for "From" and "to" strings

Advanced

The action links should better be transformed into buttons. If each gets a dedicated class they can even be visually reduced to icons (something like "plus, trash + clone"). The button action should result in feedback/announcements like e. g. "Values removed."

I see that this may conflict with the patch in Replace operation links in the widget with a dropbutton Replace operation links in the widget with a dropbutton Needs work . It should be possible to change that to work with buttons, too (see Paragraphs's Stable widget, Add mode "Dropdown button").

Remaining tasks

Write patches.

Discuss this with contributors over in the related issue.

📌 Task
Status

Active

Version

1.19

Component

Code - widget

Created by

🇩🇪Germany hexabinaer Berlin, Germany

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

  • Issue created by @hexabinaer
  • 🇩🇪Germany hexabinaer Berlin, Germany
  • 🇩🇪Germany hexabinaer Berlin, Germany
  • 🇩🇪Germany tobiasb Berlin
  • 🇩🇪Germany tobiasb Berlin

    For the record:

    * size comes core datetime element, should only be added, when type is text
    * same for placeholder
    * funny, but clever data-help comes from core just for IE11 https://www.drupal.org/node/3081864
    (Todo find/create core issue)

  • 🇩🇪Germany hexabinaer Berlin, Germany

    Oh, I wasn't aware of that. Thanks for the research!

  • 🇩🇪Germany tobiasb Berlin
  • Pipeline finished with Success
    3 months ago
    Total: 143s
    #296900
  • 🇳🇱Netherlands johnv

    Thanks for all your effort.

    Some questions about the MR:
    -1,7 : why remove the function name?
    -95,12, 126,9: why check for slot, nextSlot, if thisis not done in the upper lines, and also not in 198 (copy)?
    -198, -218: plese explain why 'data-drupal-selector$' is replaced by 'data-action' ? (mind the wild card) , since thisis introduced only recently.
    -198: $(this).parents('.dropbutton-wrapper') : I guess you tested with the dropbutton issue implemented?

    in OfficeHoursBaseSlot , you replace the links with 'button'. Not sure from the comments above, is this preferable to the dropbutton? Is thisin line with the drupal core standard behaviour?

  • 🇳🇱Netherlands johnv

    Just for future reference, please add inline comments like we did in the past: "// Add a label/header/title for accessibility (a11y) screen readers."

  • 🇩🇪Germany hexabinaer Berlin, Germany

    in OfficeHoursBaseSlot , you replace the links with 'button'. Not sure from the comments above, is this preferable to the dropbutton? is this preferable to the dropbutton? Is thisin line with the drupal

    @johnv this is one of the major improvements for screen reader users: buttons trigger actions/behaviour whereas links should take you to a new page. It's about semantics, not about what the element looks like. That said, a dropbutton ist just a wrapper (that must be accessible, too, of course) to save space in complex UIs. We know the concept from Views (legitimately wrapping operations links as well as from the optional Paragraphs dropbutton widget (wrapping buttons).

    It is an ongoing process to replace inappropriate elements, in core as well as in contrib.

  • Pipeline finished with Success
    3 months ago
    Total: 145s
    #298220
  • Pipeline finished with Success
    3 months ago
    Total: 172s
    #298854
  • Pipeline finished with Failed
    3 months ago
    Total: 162s
    #298892
  • Pipeline finished with Success
    3 months ago
    Total: 185s
    #298903
  • 🇩🇪Germany tobiasb Berlin

    @johnv It is better to write your questions in the MR.

    * IIFEs does not have a function name. example: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/misc/ajax.js?...

    * The check for slot is gone

    * I reuse the pattern data-drupal-selector again

    Drupal core does not support native buttons via form api, therefore we hardcode the buttons. But I added a todo with a link to 📌 Use form element type instead of Needs work .

  • Pipeline finished with Success
    3 months ago
    Total: 171s
    #298912
  • 🇩🇪Germany hexabinaer Berlin, Germany

    @johnv re.

    I guess you tested with the dropbutton issue implemented?

    Not exactly but we took the understandable user story into account. Buttons would of course take up even more space than the links. tobiasb took another turn on the code, added comments (he says sorry for adding in late) and did some refactoring.

    A follow-up idea would be to give site-builders the option to decide whether they want to wrap the options in a dropbutton or not.

    Further answers to your questions (or new ones): let's use code comment threads to make sure we're still referencing to the same lines of code.

    • johnv committed 0c04d090 on 8.x-1.x
      Issue #3476793 by tobiasb, hexabinaer: Fix accessibility issues in form...
  • 🇳🇱Netherlands johnv

    Above patch adds the Announcement and some coding standards.
    I also added '#wrapper_attributes' => ['header'] to Week and List, next to Exceptions

    The attached file contains the remainder of the patch. Sorry for not using fancy tools.

    For the time element, need to check that separately - perhaps in a separate ticket?
    For the dropbutton, I'd like to combine with aforementioned Replace operation links in the widget with a dropbutton Needs work . I will update that ticket.
    For "Action links have an empty href attribute, no aria attributes", I see no other way atm?

  • 🇩🇪Germany hexabinaer Berlin, Germany

    Looking into it soon.

    Just to let you know, I noticed one more: The season titles should rather be rendered in <caption> markup. Replacing the weekday table header cell with it might be confusing (arguably). It would be helpful for theming, too because season names might consume more space that the weekdays (especially when using 2ch or 3ch abbreviations).

    I'll get back to that.

  • Assigned to tobiasb
  • Status changed to Needs work 11 days ago
  • 🇳🇱Netherlands johnv

    @hexabinaer, at least in the 'table' formatter, to me it seems the season title is already in the caption.

  • 🇳🇱Netherlands johnv

    Let's reopen this issue, or open a new one, when we find something to improve.

Production build 0.71.5 2024