Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added caption role to table example #1484

Closed
wants to merge 10 commits into from
8 changes: 7 additions & 1 deletion examples/table/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h2 id="ex_label">Example</h2>
<div role="separator" id="ex_start_sep" aria-labelledby="ex_start_sep ex_label" aria-label="Start of"></div>
<div id="ex1">
<div role="table" aria-label="Students" aria-describedby="students_table_desc">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to our table naming guidance, the aria-describedby is superfluous on table elements if a caption is present. I assume this would be true if the the element is an ARIA caption as well.

<div id="students_table_desc">Students currently enrolled in WAI-ARIA 101 for the coming semester</div>
<div role="caption" id="students_table_desc">Students currently enrolled in WAI-ARIA 101 for the coming semester</div>
<div role="rowgroup">
<div role="row">
<span role="columnheader">First Name</span>
Expand Down Expand Up @@ -121,6 +121,12 @@ <h2 id="rps_label">Role, Property, State, and Tabindex Attributes</h2>
<td><code>div</code></td>
<td>Refers to the element that serves as the caption for the table.</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This table row would need to be removed if aria-describedby is not needed.

</tr>
<tr data-test-id="caption-role">
<th scope="row"><code>caption</code></th>
<td></td>
<td><code>div</code></td>
<td>The element containing a description of the table contents.</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest wording consistent with other roles

Suggested change
<td>The element containing a description of the table contents.</td>
<td>Identifies the element as a caption for the table.</td>

</tr>
<tr data-test-id="rowgroup-role">
<th scope="row"><code>rowgroup</code></th>
<td></td>
Expand Down
11 changes: 7 additions & 4 deletions test/tests/table_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ ariaTest('"aria-describedby" attribute on table element', exampleFile, 'table-ar
await assertAriaDescribedby(t, ex.tableSelector);
});

ariaTest('role="caption" element exists', exampleFile, 'caption-role', async (t) => {
await assertAriaRoles(t, 'ex1', 'caption', 1, 'div');
});

ariaTest('role="rowgroup" exists', exampleFile, 'rowgroup-role', async (t) => {

const rowgroups = await t.context.queryElements(t, ex.tableSelector + ' [role="rowgroup"]');

t.is(
Expand All @@ -43,7 +46,7 @@ ariaTest('role="rowgroup" exists', exampleFile, 'rowgroup-role', async (t) => {


ariaTest('role="row" exists', exampleFile, 'row-role', async (t) => {

const rows = await t.context.queryElements(t, ex.tableSelector + ' [role="rowgroup"] [role="row"]');

t.is(
Expand All @@ -55,7 +58,7 @@ ariaTest('role="row" exists', exampleFile, 'row-role', async (t) => {


ariaTest('role="columnheader" exists', exampleFile, 'columnheader-role', async (t) => {

const columnheaders = await t.context.queryElements(t, ex.tableSelector + ' [role="rowgroup"] [role="row"] [role="columnheader"]');

t.is(
Expand All @@ -67,7 +70,7 @@ ariaTest('role="columnheader" exists', exampleFile, 'columnheader-role', async (
});

ariaTest('role="cell" exists', exampleFile, 'cell-role', async (t) => {

const cells = await t.context.queryElements(t, ex.tableSelector + ' [role="rowgroup"] [role="row"] [role="cell"]');

t.is(
Expand Down