Skip to content

Commit 8bb39f2

Browse files
Remove incorrect roles from accordion, tweak/expand accessibility info, use buttons for accordion
* Remove incorrect roles from accordion, tweak/expand accessibility info * Use `<button>` elements rather than links for the accordion
1 parent dccd003 commit 8bb39f2

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

docs/4.0/components/collapse.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,45 +66,45 @@ Multiple `<button>` or `<a>` can show and hide an element if they each reference
6666
Using the [card]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/card/) component, you can extend the default collapse behavior to create an accordion.
6767

6868
{% example html %}
69-
<div id="accordion" role="tablist">
69+
<div id="accordion">
7070
<div class="card">
71-
<div class="card-header" role="tab" id="headingOne">
71+
<div class="card-header" id="headingOne">
7272
<h5 class="mb-0">
73-
<a data-toggle="collapse" href="#collapseOne" role="button" aria-expanded="true" aria-controls="collapseOne">
73+
<button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
7474
Collapsible Group Item #1
75-
</a>
75+
</button>
7676
</h5>
7777
</div>
7878

79-
<div id="collapseOne" class="collapse show" role="tabpanel" aria-labelledby="headingOne" data-parent="#accordion">
79+
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
8080
<div class="card-body">
8181
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
8282
</div>
8383
</div>
8484
</div>
8585
<div class="card">
86-
<div class="card-header" role="tab" id="headingTwo">
86+
<div class="card-header" id="headingTwo">
8787
<h5 class="mb-0">
88-
<a class="collapsed" data-toggle="collapse" href="#collapseTwo" role="button" aria-expanded="false" aria-controls="collapseTwo">
88+
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
8989
Collapsible Group Item #2
90-
</a>
90+
</button>
9191
</h5>
9292
</div>
93-
<div id="collapseTwo" class="collapse" role="tabpanel" aria-labelledby="headingTwo" data-parent="#accordion">
93+
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
9494
<div class="card-body">
9595
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
9696
</div>
9797
</div>
9898
</div>
9999
<div class="card">
100-
<div class="card-header" role="tab" id="headingThree">
100+
<div class="card-header" id="headingThree">
101101
<h5 class="mb-0">
102-
<a class="collapsed" data-toggle="collapse" href="#collapseThree" role="button" aria-expanded="false" aria-controls="collapseThree">
102+
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
103103
Collapsible Group Item #3
104-
</a>
104+
</button>
105105
</h5>
106106
</div>
107-
<div id="collapseThree" class="collapse" role="tabpanel" aria-labelledby="headingThree" data-parent="#accordion">
107+
<div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordion">
108108
<div class="card-body">
109109
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
110110
</div>
@@ -117,7 +117,9 @@ Using the [card]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/card
117117

118118
Be sure to add `aria-expanded` to the control element. This attribute explicitly conveys the current state of the collapsible element tied to the control to screen readers and similar assistive technologies. If the collapsible element is closed by default, the attribute on the control element should have a value of `aria-expanded="false"`. If you've set the collapsible element to be open by default using the `show` class, set `aria-expanded="true"` on the control instead. The plugin will automatically toggle this attribute on the control based on whether or not the collapsible element has been opened or closed (via JavaScript, or because the user triggered another control element also tied to the same collapsbile element). If the control element's HTML element is not a button (e.g., an `<a>` or `<div>`), the attribute `role="button"` should be added to the element.
119119

120-
Additionally, if your control element is targeting a single collapsible element – i.e. the `data-target` attribute is pointing to an `id` selector – you may add an additional `aria-controls` attribute to the control element, containing the `id` of the collapsible element. Modern screen readers and similar assistive technologies make use of this attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.
120+
If your control element is targeting a single collapsible element – i.e. the `data-target` attribute is pointing to an `id` selector – you should add the `aria-controls` attribute to the control element, containing the `id` of the collapsible element. Modern screen readers and similar assistive technologies make use of this attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.
121+
122+
Note that Bootstrap's current implementation does not cover the various keyboard interactions described in the [WAI-ARIA Authoring Practices 1.1 accordion pattern](https://www.w3.org/TR/wai-aria-practices-1.1/#accordion) - you will need to include these yourself with custom JavaScript.
121123

122124
## Usage
123125

0 commit comments

Comments
 (0)