Problem/Motivation
When the same Views Bootstrap Accordion display is rendered more than once on a page with different arguments (for example two embeddings of the same view with different contextual filters), the markup produces duplicate id attributes. Duplicate IDs are an accessibility issue: they break the unique-ID requirement in HTML and can confuse assistive technologies.
Collapse panel IDs already use the unique instance prefix from ViewsBootstrap::getUniqueId() / Html::getUniqueId():
{{ id }}-collapse-{{ clean_key }}Header IDs do not. They are built only from the group key:
heading{{ clean_key }}With identical group values (e.g. years 2026, 2025, 2024), both accordions emit the same header IDs (headingkey--2026, etc.). aria-labelledby on the second accordion’s panels then points at the first accordion’s headers, so assistive tech can announce the wrong label.
Steps to reproduce
- Create a view using the Bootstrap Accordion style, with grouping that produces stable keys (e.g. year).
- Place that view display twice on the same page with different arguments (e.g. two embeddings of the same display with different contextual filter values).
- Inspect the markup.
- Observe duplicated header IDs such as
headingkey--2026, andaria-labelledbyon the second accordion resolving to headers from the first.
Proposed resolution
Prefix accordion header IDs with the same unique {{ id }} already used for collapse panels, and keep aria-labelledby in sync:
{% set heading_id = id ~ '-heading-' ~ clean_key %}
Use id="{{ heading_id }}" on the header and aria-labelledby="{{ heading_id }}" on the panel. data-bs-target / data-bs-parent are already unique and do not need changes.
Remaining tasks
- Review the patch / merge request
- Commit and tag a new release once the fix is merged
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | fix-accordion-duplicate-heading-ids.patch | 1.52 KB | tiago |
Issue fork views_bootstrap-3614071
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
Comment #3
tiago commentedMR!62 solves the issue.
I have also attached the patch file here.
Comment #6
shelane