Skip to content

Table headers - No ARIA tables and TF feedback #1971

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

Draft
wants to merge 32 commits into
base: develop
Choose a base branch
from

Conversation

ajanec01
Copy link
Collaborator

@ajanec01 ajanec01 commented Nov 16, 2022

A few of changes to Table header cell has assigned cells.

The only reliably way of determining how table headers are assigned is in the HTML specification. It is unclear how ARIA table headers are assigned to cells so they are now omitted from the rule.

The update includes changes made in response to the 1st Task Force feedback and the 2nd Task Force feedback.

Closes #1545 and closes #1517

Call for review- 2 weeks


How to Review And Approve

  • Go to the “Files changed” tab
  • Here you will have the option to leave comments on different lines.
  • Once the review is completed, find the “Review changes” button in the top right, select “Approve” (if you are really confident in the rule) or "Request changes" and click “Submit review”.
  • Make sure to also review the proposed Call for Review period. In case of disagreement, the longer period wins.

@ajanec01 ajanec01 added the Rule Update Use this label for an existing rule that is being updated label Nov 16, 2022
@ajanec01 ajanec01 self-assigned this Nov 16, 2022
@Jym77 Jym77 self-requested a review November 24, 2022 15:14
- **visible** the `table` element is [visible][]; and
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and
- **non-empty data cell** the `table` element has at least one non-empty `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child] or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child].
- **no explicit role** none of the elements that make up the [table model][] have an [explicit semantic role][].
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if the explicit role is the same as the implicit one? (<th role="rowheader">)
Plus, this seems to be a bullet in the outer list (used by the th) but rather refers to the table (i.e. the inner list).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've chosen the safer version as we don't know for sure what browsers do when aria roles are added as it's not in the spec. UA have their own way of assigning headers when aria is used and at the moment we can only guess. I understand that the same implicit role would work fine in practice but I'm slightly concerned we may expose the rule to some weird, uncommon example that will be a false positive.

Do you think the rule will benefit from adding an exception for the same explicit role?

Hmm... this role applies to all the elements that make up the test target's table element, so table,thead, tbody,tr, etc. I thought that the table model definition was explicit enough. Open to suggestions on this.

Comment on lines 30 to 34
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true:
- **visible** the `table` element is [visible][]; and
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and
- **non-empty data cell** the `table` element has at least one non-empty `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child] or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child].
- **no explicit role** none of the elements that make up the [table model][] have an [explicit semantic role][].
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that the th element is no more required to be visible or included in the accessibility tree 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, not sure what you mean by this. Are you suggesting that the "included in the accessibility tree" part in the first paragraph of the applicability section is not necessary?

Comment on lines 30 to 34
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true:
- **visible** the `table` element is [visible][]; and
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and
- **non-empty data cell** the `table` element has at least one non-empty `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child] or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child].
- **no explicit role** none of the elements that make up the [table model][] have an [explicit semantic role][].
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm afraid the nested lists will prove difficult to read.
What about defining a "proper table" or something as a table element matching all the conditions here, and just require the th to be "part of a proper table"? The def might be re-usable by other rules about HTML tables.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, sounds good to me!

- the element's closest ancestor in the [flat tree][] that is a [semantic][semantic role] [table][] or [grid][] is [included in the accessibility tree][].
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true:
- **visible** the `table` element is [visible][]; and
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤔 Not fully sure about that one.

<table>
<tr>
  <th>Opening hours</th> <td>8-17</td>
</tr>
</table>

sounds like a reasonable case.
And

<table>
<tr>
  <th>Opening hours</th> <th>Mon-Fri</th> <td>8-17</td>
</tr>
</table>

sounds like a bad one (where the first th is not assigned to anything due to the second one (or maybe it is still assigned to the second th, can't remember…))

(OTOH, restricting Applicability won't create false positives, so it won't really hurt…)

Copy link
Member

Choose a reason for hiding this comment

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

Agree with Jean-Yves. The first case is reasonable, and I can't come up with a good reason for us to ignore it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The question is how much value we get out of that example? Not too much if you think that there is only one row and row headers are useful when you navigate between the rows. This change corresponds to Wilco's survey comments. I'm trying to avoid the below scenario:

     <table>
       <thead>
         <tr>
         <td>N/a
         <th>2008
         <th>2007
         <th>2006
       <tbody>
         <tr>
         <td>
         <td>
         <td>
         <td>
     </table>

Because tables are two dimensional the most we will get out of this rule if there will be at least two rows and there will be a non-empty data cell in a row that follows a column header row or in any of the rows providing that there are row headers in them.

Would you agree?

Copy link
Member

Choose a reason for hiding this comment

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

I don't understand how your example applies to this condition (your example has 2 rows, therefore this conditions applies) :-)

But I can live with this condition. As Jean-Yves mentioned, it will only limit what is applicable, not create false positives. Although I still can't see why we should not consider the one row example Jean-Yves described.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The problem that the above example introduces is that there is no use of the <th> elements, technically they do not have an assigned <td> element and they should not be column headers but the implementation varies. My condition requires at least one non-empty <td> element in the second row, meaning that it is clear visually that there is a relationship between a data cell and a column header cell.

- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true:
- **visible** the `table` element is [visible][]; and
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and
- **non-empty data cell** the `table` element has at least one non-empty `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child] or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child].
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also not sure about that due to multi-headers.

Opening hours:
<table>
<tr>
  <th rowspan="2">Morning</th> <th>Mon-Fri</th> <td>8-12</td>
</tr>
<tr>
  <!-- no first column --> <th>Sat-Sun</th> <td>10-12</td>
</tr>
<table>

would have at least 2 th children in the first row without it being a "headers row".

(here also, no real harm in restricting the Applicability)

Comment on lines +183 to +213
<html>
<head>
<meta charset="utf-8" />
<title>Failed Example 1</title>
<style>
table {
border-collapse: collapse;
border: hidden;
}
tr td,
tr th {
border: 1px solid grey;
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>Rate</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>15%</td>
</tr>
</tbody>
</table>
</body>
</html>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<html>
<head>
<meta charset="utf-8" />
<title>Failed Example 1</title>
<style>
table {
border-collapse: collapse;
border: hidden;
}
tr td,
tr th {
border: 1px solid grey;
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>Rate</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>15%</td>
</tr>
</tbody>
</table>
</body>
</html>
<style>
table {
border-collapse: collapse;
border: hidden;
}
tr td,
tr th {
border: 1px solid grey;
}
</style>
<table>
<thead>
<tr>
<th>Rate</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>15%</td>
</tr>
</tbody>
</table>

(not sure how much the style is needed, though)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought it should be added in response to @kengdoj comment

From https://www.w3.org/TR/wai-aria-1.1/#columnheader: The columnheader establishes a relationship between it and all cells in the corresponding column. When there are no cells under a column header (as in Fail Ex 1), I don't think 1.3.1 requires that it can't be a column header without a data cell.

My point here is, visually looks like there is a cell for the second column header but programmatically there isn't one so it is a failure. Would you agree?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That pasted comment is from Q5 in the survey so I was a bit confused.

My survey comment for this example was in Q4 and is below. It didn't look like there's a cell to me, though I can understand that someone may assume one:

Fail Ex 1's table has no data cell under the second column and programmatically matches the presentation. Not sure this is a failure of 1.3.1.

- the element's closest ancestor in the [flat tree][] that is a [semantic][semantic role] [table][] or [grid][] is [included in the accessibility tree][].
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true:
- **visible** the `table` element is [visible][]; and
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and
Copy link
Member

Choose a reason for hiding this comment

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

Agree with Jean-Yves. The first case is reasonable, and I can't come up with a good reason for us to ignore it.

Copy link
Member

@carlosapaduarte carlosapaduarte left a comment

Choose a reason for hiding this comment

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

Still some issues to keep working on

- the element is [included in the accessibility tree][]; and
- the element has at least one ancestor in the [flat tree][] that is a [semantic][semantic role] [table][] or [grid][]; and
- the element's closest ancestor in the [flat tree][] that is a [semantic][semantic role] [table][] or [grid][] is [included in the accessibility tree][].
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true:
- **in a table**: the `th` element is a [descendant][] of a `table` element for which all of the following are true:

Need to add the colon after the name of all conditions

- the element's closest ancestor in the [flat tree][] that is a [semantic][semantic role] [table][] or [grid][] is [included in the accessibility tree][].
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true:
- **visible** the `table` element is [visible][]; and
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand how your example applies to this condition (your example has 2 rows, therefore this conditions applies) :-)

But I can live with this condition. As Jean-Yves mentioned, it will only limit what is applicable, not create false positives. Although I still can't see why we should not consider the one row example Jean-Yves described.

- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true:
- **visible** the `table` element is [visible][]; and
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and
- **non-empty data cell** the `table` element has at least one [non-empty][] `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child] or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child].
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- **non-empty data cell** the `table` element has at least one [non-empty][] `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child] or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child].
- **non-empty data cell** the `table` element has at least one [non-empty][] `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child]; or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child].

Interestingly, this condition would make Jean-Yves' one row example, applicable.

@HelenBurge
Copy link
Collaborator

Hi @ajanec01 - I was wondering if there was any updates for this as waiting on it for a TF assignment I need to action.

FYI @kengdoj

@ajanec01
Copy link
Collaborator Author

ajanec01 commented Jun 6, 2023

Hi @HelenBurge
Apologies but I won't be able to work on this for some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rule Update Use this label for an existing rule that is being updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should all table header cells have assigned data cells? "Table header cell has assigned cells" (d0f69e): test tables and grids separately?
5 participants