Broken aria-describedby in radios and checkboxes

Created on 26 December 2016, over 7 years ago
Updated 12 June 2024, 13 days ago

Problem/Motivation

Example stack trace:

Warning: Undefined array key "aria-describedby" in webform_process_options() (line 1093 of .../modules/contrib/webform/webform.module)
#0 .../core/includes/bootstrap.inc(164): _drupal_error_handler_real()
#1 .../modules/contrib/webform/webform.module(1093): _drupal_error_handler()
#2 [internal function]: webform_process_options()
#3 .../core/lib/Drupal/Core/Form/FormBuilder.php(1025): call_user_func_array()
#4 .../core/lib/Drupal/Core/Form/FormBuilder.php(1088): Drupal\Core\Form\FormBuilder->doBuildForm()
#5 .../core/lib/Drupal/Core/Form/FormBuilder.php(1088): Drupal\Core\Form\FormBuilder->doBuildForm()
#6 .../core/lib/Drupal/Core/Form/FormBuilder.php(579): Drupal\Core\Form\FormBuilder->doBuildForm()
#7 .../core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm()
#8 .../core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm()
#9 .../modules/contrib/webform/src/Entity/Webform.php(1257): Drupal\Core\Entity\EntityFormBuilder->getForm()
#10 .../modules/contrib/webform/src/Element/Webform.php(112): Drupal\webform\Entity\Webform->getSubmissionForm()
#11 [internal function]: Drupal\webform\Element\Webform::preRenderWebformElement()

Steps to reproduce

  1. Go to admin/config/people/accounts
  2. Navigate to REGISTRATION AND CANCELLATION > When cancelling a user account
  3. Inspect the radio buttons. Seeing that aria-describedby="edit-user-cancel-method--description" which edit-user-cancel-method--description doesn't exists.

Those 3 radio buttons don't have any description. So I think they don't need to have aria-describedby attribute.
For example, in REGISTRATION AND CANCELLATION > Who can register accounts?, the radio buttons don't have aria-describedby attribute since they don't have description.
However, the description below (Users with the Select method ...) is a description of the fieldset wrapper.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
User moduleΒ  β†’

Last updated 1 minute ago

Created by

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.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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 Kingdom kalpaitch

    Following on from @codebymikey's point #29 I've also identified this happens to the 'container' element too, (albeit with the caveat that the container element does not support the #description attribute):

    $form['element'] = [
          '#type' => 'container',
          '#description' => 'A description added to the container.'
    ];
    

    This will result in a container wrapper being rendered with an incorrect 'aria-describedby' attribute.

    Following on from @andrewmacpherson's comment #22, I agree there needs to be a more extensible way to declare a form element as a composite form element. But there are also needs to be some consideration for other render elements which get the 'aria-describedby' attribute added.

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    Liam Morland β†’ made their first commit to this issue’s fork.

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    I have made a merge request with patch 17 rebased onto 11.x.

  • Pipeline finished with Success
    3 months ago
    Total: 505s
    #124455
  • Pipeline finished with Failed
    13 days ago
    #197329
  • Pipeline finished with Canceled
    13 days ago
    Total: 310s
    #197345
  • I agree with #25, that we should use something more extensible. However, I don't think either of the suggestions is enough information for making it work. The issue is in the FormBuilder class, and at that point, you don't have instances of ElementInterface, you have a render array. So you can't do an instanceof test.

    It might be easier to add an attribute #is_composite to the render array?

    Or if I'm wrong, then I would say it's probably better to have CompositeFormElementInterface, because there is also a CompositeFormElementTrait. So you could even put isComposite in the trait, and it would be added to any contrib/custom classes using the trait as well.

  • Pipeline finished with Success
    13 days ago
    Total: 542s
    #197353
Production build 0.69.0 2024