Skip to content

Commit 031695e

Browse files
pat270XhmikosR
authored andcommitted
Add missing role="button" in collapse examples. (#24725)
1 parent 5a2d6c7 commit 031695e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

docs/4.0/components/collapse.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ You can use a link with the `href` attribute, or a button with the `data-target`
1818

1919
{% example html %}
2020
<p>
21-
<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
21+
<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
2222
Link with href
2323
</a>
2424
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
@@ -39,7 +39,7 @@ Multiple `<button>` or `<a>` can show and hide an element if they each reference
3939

4040
{% example html %}
4141
<p>
42-
<a class="btn btn-primary" data-toggle="collapse" href="#multiCollapseExample1" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a>
42+
<a class="btn btn-primary" data-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a>
4343
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Toggle second element</button>
4444
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button>
4545
</p>
@@ -70,7 +70,7 @@ Using the [card]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/card
7070
<div class="card">
7171
<div class="card-header" role="tab" id="headingOne">
7272
<h5 class="mb-0">
73-
<a data-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
73+
<a data-toggle="collapse" href="#collapseOne" role="button" aria-expanded="true" aria-controls="collapseOne">
7474
Collapsible Group Item #1
7575
</a>
7676
</h5>
@@ -85,7 +85,7 @@ Using the [card]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/card
8585
<div class="card">
8686
<div class="card-header" role="tab" id="headingTwo">
8787
<h5 class="mb-0">
88-
<a class="collapsed" data-toggle="collapse" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
88+
<a class="collapsed" data-toggle="collapse" href="#collapseTwo" role="button" aria-expanded="false" aria-controls="collapseTwo">
8989
Collapsible Group Item #2
9090
</a>
9191
</h5>
@@ -99,7 +99,7 @@ Using the [card]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/card
9999
<div class="card">
100100
<div class="card-header" role="tab" id="headingThree">
101101
<h5 class="mb-0">
102-
<a class="collapsed" data-toggle="collapse" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
102+
<a class="collapsed" data-toggle="collapse" href="#collapseThree" role="button" aria-expanded="false" aria-controls="collapseThree">
103103
Collapsible Group Item #3
104104
</a>
105105
</h5>
@@ -118,7 +118,7 @@ You can also create accordions with custom markup. Add the `data-children` attri
118118
{% example html %}
119119
<div id="exampleAccordion" data-children=".item">
120120
<div class="item">
121-
<a data-toggle="collapse" data-parent="#exampleAccordion" href="#exampleAccordion1" aria-expanded="true" aria-controls="exampleAccordion1">
121+
<a data-toggle="collapse" data-parent="#exampleAccordion" href="#exampleAccordion1" role="button" aria-expanded="true" aria-controls="exampleAccordion1">
122122
Toggle item
123123
</a>
124124
<div id="exampleAccordion1" class="collapse show" role="tabpanel">
@@ -128,7 +128,7 @@ You can also create accordions with custom markup. Add the `data-children` attri
128128
</div>
129129
</div>
130130
<div class="item">
131-
<a data-toggle="collapse" data-parent="#exampleAccordion" href="#exampleAccordion2" aria-expanded="false" aria-controls="exampleAccordion2">
131+
<a data-toggle="collapse" data-parent="#exampleAccordion" href="#exampleAccordion2" role="button" aria-expanded="false" aria-controls="exampleAccordion2">
132132
Toggle item 2
133133
</a>
134134
<div id="exampleAccordion2" class="collapse" role="tabpanel">
@@ -142,7 +142,7 @@ You can also create accordions with custom markup. Add the `data-children` attri
142142

143143
## Accessibility
144144

145-
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).
145+
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.
146146

147147
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.
148148

0 commit comments

Comments
 (0)