Fix the accordion title id property to match the aria-labelledby reference

Created on 27 September 2024, 1 day ago

Problem/Motivation

The accordion item, which is rendered within template accordions.macros.twig, is delivering a wrong title tag id that does not correspond to the property aria-labelledby which is rendered by element .accordion-collapse right underneath it.

Property aria-labelledby is crafting an unique id by incorporating both a random integer, and the loop index number. The title tag id does not match that pattern, as it carries the random integer only.

This is how the rendered HTML of one such accordion would be rendered:

<div class="accordion" id="accordion-5878">
          <div class="accordion-item">
        <h3 class="accordion-header" id="#collapse__heading-5878">
          <button class="accordion-button " type="button" data-bs-toggle="collapse" data-bs-target="#collapse-58781" aria-expanded="true" aria-controls="collapse-58781">
            Accordion Item #1
          </button>
        </h3>

        <div id="collapse-58781" class="accordion-collapse collapse show" aria-labelledby="#collapse__heading-58781" data-bs-parent="#accordion-5878">
          <div class="accordion-body">
            <strong>This is the first item's accordion body.</strong> It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body

, though the transition does limit overflow.

Note the id of the <h3 /> element is not matching property aria-labelledby.

Steps to reproduce

Install the module and navigate to /ui-kit; click the Accordion link and confirm elements don't match.

Proposed resolution

Fix the ID of the title element, and make it match with the aria-labelledby property.

Remaining tasks

--

User interface changes

--

API changes

--

Data model changes

--

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇷Brazil mabho Rio de Janeiro, RJ

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

Production build 0.71.5 2024