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

--

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:

Comments

mabho created an issue. See original summary.

mabho’s picture

Status: Active » Needs review
aaronchristian’s picture

Status: Needs review » Reviewed & tested by the community

Good catch Marcos!

Tested, looks good :)

aaronchristian’s picture

aaronchristian’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.