0

I am trying to fix Broken ARIA reference errors notified by Wave tool in chrome for my custom module web pages and Drupal 8 core login form. Sample error in login form is mentioned below for username field. How to fix these issues. For every user control I have this site wide.

Error at username text box:

*aria-describedby="edit-name--description", aria-required="true"

(An aria-labelledby or aria-describedby reference exists, but the target for the reference does not exist.)

I am not able to find aria-describedby attribute itself in the code for the controls. So, I am not sure how to fix them.

1

The attribute is only added if the element has a description. This is the code from the FormBuilder that does it:

// Add the aria-describedby attribute to associate the form control with its
// description.
if (!empty($element['#description'])) {
  $element['#attributes']['aria-describedby'] = $element['#id'] . '--description';
}

The idea being that when the input is rendered in form-element.html.twig, the description is rendered alongside it with a matching ID. For example this is how the core stable theme handles it:

{% if description_display in ['after', 'invisible'] and description.content %}
  <div{{ description.attributes.addClass(description_classes) }}>
    {{ description.content }}
  </div>
{% endif %}

So it seems likely there aren't that many possible sources for the problem. These are the only ones I could come up with:

  1. You're using a core theme, or a derivative of one which still renders the description in form-element.html.twig, and something in the system is setting the description display to a value other than 'after' and 'invisible', causing it not to be rendered.
  2. You're using a non-core theme, which overrides form-element.html.twig, and doesn't render the description.
  3. Something in the system is changing either the value in the input's aria-describedby attribute, or the ID of the description element in the element template, causing them not to match.
  4. Some combination of the above.

Hopefully that's enough to go on.

  • My case is the second one. Can you suggest what should I be looking into to fix this. – user3324848 Sep 25 '18 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.