Problem/Motivation

Like all form elements, details elements are assigned an aria-describedby attribute with a value of {element-id}--description. The problem is that the actual description is not given this ID. It is properly assigned for other form elements (at least all that I've tested).

This attribute is set in FormBuilder.php on line 971 (as of 8.3.4):

if (!empty($element['#description'])) {
  $element['#attributes']['aria-describedby'] = $element['#id'] . '--description';
}

The default template for a details element is in the system module's details.html.twig:

{{ description }}

The main theme template is in classy's details.html.twig:

<div class="details-description">{{ description }}</div>

No where is this proper ID being set.

The description attributes seem to be provided in form.inc within template_preprocess_form_element() and template_preprocess_fieldset(), but not within template_preprocess_details().

Tested with Bartik, Classy, and Seven.

Proposed resolution

I think the solution here is to add the same code from template_preprocess_fieldset() to template_preprocess_details(). Then in all details.html.twig, we include something like:

{%- if description.content -%}
  <div{{ description.attributes.addClass('description-details') }}>{{ description.content }}</div>
{%- endif -%}

Remaining tasks

Provide a patch.

User interface changes

aria-describedby attributes will all be correct for details elements by properly wrapping the description in a DIV with the correct ID.

Issue fork drupal-2896169

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mstef created an issue. See original summary.

mstef’s picture

Issue summary: View changes
mstef’s picture

Component: forms system » render system

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andrewmacpherson’s picture

Tagging this, will look at it soon. I only noticed this issue because the Webform accessibility handbook page links here.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

sahal_va’s picture

Status: Active » Needs review
FileSize
2.28 KB

Created the patch for above issue.

sahal_va’s picture

FileSize
2.19 KB

Status: Needs review » Needs work

The last submitted patch, 12: 2896169-11.patch, failed testing. View results

joseph.olstad’s picture

I had a look at the patch quickly, looks good so far, looks like remaining work is on refactoring the simpletests.

sahal_va’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
5.38 KB

Corrected patch.

sahal_va’s picture

Status: Reviewed & tested by the community » Needs review
sahal_va’s picture

Status: Needs review » Needs work
ridhimaabrol24’s picture

Status: Needs work » Needs review
FileSize
5.63 KB
617 bytes

Fixing failed tests!

Status: Needs review » Needs work

The last submitted patch, 19: 2896169-19.patch, failed testing. View results

ridhimaabrol24’s picture

Fixing failed test!

ridhimaabrol24’s picture

Status: Needs work » Needs review
FileSize
6.59 KB
829 bytes

Correcting the above error!

Status: Needs review » Needs work

The last submitted patch, 22: interdiff_19-22.patch, failed testing. View results

ridhimaabrol24’s picture

Status: Needs work » Needs review

Added interdiff.patch by mistake instead of interdiff.txt. Hence its failing. However the patch in #22 passes the test bot. Hence moving this to 'Needs Review'.

sahal_va’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
78.23 KB
81.21 KB
60.14 KB
87.13 KB
86.96 KB

I tested the issue with Bartik, Claro, Classy, and Seven. This seems to be fixed.
Attaching the screenshots below for Seven.

Hi @ridhimaabrol24
Though changes in both patches are same, why #17 fails? I think I'm missing something essential for auto testing??

joseph.olstad’s picture

+1 , great work! I checked the drupal bootstrap contrib theme (version 3x) and it doesn't override this twig so this fix should also fix the for bootstrap installs as well and likely others.

Get it in!

ridhimaabrol24’s picture

Hi @sahal_va
Please see the interdiff attached in #19 to see what fixed those tests!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 22: interdiff_19-22.patch, failed testing. View results

mohit_aghera’s picture

Status: Needs work » Needs review

Changing to needs review as patch is already passing all the test cases.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

hswong3i made their first commit to this issue’s fork.

hswong3i’s picture

Version: 9.3.x-dev » 9.4.x-dev

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
150 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mgifford’s picture

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.