Skip to content

Conversation

smhigley
Copy link
Contributor

@smhigley smhigley commented Jan 12, 2024

Closes #1194

As discussed in the issue, this PR adds normative wording on requiring user agents to calculate aria-level, aria-posinset, and aria-setsize. It also adds a section outlining how to compute each attribute, based on the current Core AAM wording that will be removed after this is merged.

PR tracking

Check these when the relevant issue or PR has been made, OR after you have confirmed the
related change is not necessary (add N/A). Leave unchecked if you are unsure. Read the
Process Document or
Test Overview for more information.

  • Related Core AAM Issue/PR:
  • Related AccName Issue/PR: N/A
  • Any other dependent changes? N/A

Test, Documentation and Implementation tracking

Once this PR and all related PRs have been been approved by the working group, tests
should be written and issues should be opened on browsers. Add N/A and check when not
applicable.


Preview | Diff

index.html Outdated
<p>Levels increase with depth. If the <abbr title="Document Object Model">DOM</abbr> ancestry does not accurately represent the level, authors SHOULD explicitly define the <pref>aria-level</pref> <a>attribute</a>.</p>
<p>This attribute is applied to elements that act as leaf nodes within the orientation of the set, for example, on elements with role <rref>treeitem</rref> rather than elements with role <rref>group</rref>. This means that multiple elements in a set can have the same value for this attribute. Although it would be less repetitive to provide a single value on the container, restricting this to leaf nodes ensures that there is a single way for <a>assistive technologies</a> to use the attribute.</p>
<p>If the <abbr title="Document Object Model">DOM</abbr> ancestry accurately represents the level, the <a>user agent</a> can calculate the level of an item from the document structure. This attribute can be used to provide an explicit indication of the level when that is not possible to calculate from the document structure or the <pref>aria-owns</pref> attribute. User agent support for automatic calculation of level might vary; authors SHOULD test with [=user agents=] and assistive technologies to determine whether this attribute is needed. If the author intends for the user agent to calculate the level, the author SHOULD omit this attribute.</p>
<p>If the <abbr title="Document Object Model">DOM</abbr> ancestry accurately represents the level, the <a>user agent</a> can calculate the level of an item from the document structure as defined in the <a href="#tree_groups">Calculating Group Position</a> section. This attribute can be used to provide an explicit indication of the level when that is not possible to calculate from the document structure or the <pref>aria-owns</pref> attribute. User agent support for automatic calculation of level might vary; authors SHOULD test with [=user agents=] and assistive technologies to determine whether this attribute is needed. If the author intends for the user agent to calculate the level, the author SHOULD omit this attribute.</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

VoiceOver assumes no level on headings when not supplied by an author, and just speaks "heading" not the more verbose "heading level 0" or an arbitrary "heading level 2." I worry this change will advise AT to verbosely convey info that the author may not have intended.

Copy link
Member

Choose a reason for hiding this comment

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

A quick test indicates that Chrome and Firefox appear to calculate a level of 2 for a role=heading with no level.

While NVDA and JAWS expose that level in speech and braille, Orca does not.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's unfortunate the didn't catch that this ARIA 1.1 spec change increased SR verbosity unnecessarily, but since we didn't, and the implementations have moved on, I will forego my worry. It's not so problematic a user change that we should break the IDL reflection and force multiple implementations to revert it.

@pkra pkra added the Agenda label Jan 29, 2025
index.html Outdated
<p>Levels increase with depth. If the <abbr title="Document Object Model">DOM</abbr> ancestry does not accurately represent the level, authors SHOULD explicitly define the <pref>aria-level</pref> <a>attribute</a>.</p>
<p>This attribute is applied to elements that act as leaf nodes within the orientation of the set, for example, on elements with role <rref>treeitem</rref> rather than elements with role <rref>group</rref>. This means that multiple elements in a set can have the same value for this attribute. Although it would be less repetitive to provide a single value on the container, restricting this to leaf nodes ensures that there is a single way for <a>assistive technologies</a> to use the attribute.</p>
<p>If the <abbr title="Document Object Model">DOM</abbr> ancestry accurately represents the level, the <a>user agent</a> can calculate the level of an item from the document structure. This attribute can be used to provide an explicit indication of the level when that is not possible to calculate from the document structure or the <pref>aria-owns</pref> attribute. User agent support for automatic calculation of level might vary; authors SHOULD test with [=user agents=] and assistive technologies to determine whether this attribute is needed. If the author intends for the user agent to calculate the level, the author SHOULD omit this attribute.</p>
<p>If the <abbr title="Document Object Model">DOM</abbr> ancestry accurately represents the level, the <a>user agent</a> can calculate the level of an item from the document structure as defined in the <a href="#tree_groups">Calculating Group Position</a> section. This attribute can be used to provide an explicit indication of the level when that is not possible to calculate from the document structure or the <pref>aria-owns</pref> attribute. User agent support for automatic calculation of level might vary; authors SHOULD test with [=user agents=] and assistive technologies to determine whether this attribute is needed. If the author intends for the user agent to calculate the level, the author SHOULD omit this attribute.</p>
Copy link
Member

@pkra pkra Jan 29, 2025

Choose a reason for hiding this comment

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

The DOM order is mentioned and then aria-owns as an example of things being problematic - but the algorithm only operates on the accessibility tree. (The other properties also reference the DOM which seems to me should change.)

Something like

Unless required by a role, authors SHOULD not use this property; instead authors SHOULD ensure that Calculating Group Position works correctly. If that is not the case, this property MAY be used to provide explicit information of the level.

These properties nowadays almost feel like a case for #1480 to me.

index.html Outdated
@@ -11846,7 +11846,7 @@ <h2>Definitions of States and Properties (all aria-* attributes)</h2>
<p>This can be applied inside trees to tree items, to headings inside a document, to nested grids, nested tablists and to other structural items that might appear inside a container or participate in an ownership hierarchy. The value for <pref>aria-level</pref> is an integer greater than or equal to 1.</p>
<p>Levels increase with depth. If the <abbr title="Document Object Model">DOM</abbr> ancestry does not accurately represent the level, authors SHOULD explicitly define the <pref>aria-level</pref> <a>attribute</a>.</p>
Copy link
Member

Choose a reason for hiding this comment

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

I think we should remove the second sentence (see my other comment).

index.html Outdated
&lt;/ul&gt;</pre>
<p>When specifying <pref>aria-posinset</pref>, authors MUST specify a value that is an integer greater than or equal to 1, and less than or equal to the size of the set when that size is known. If authors specify <pref>aria-posinset</pref>, authors MUST also specify a value for <pref>aria-setsize</pref>.</p>
<p>When specifying <code>aria-posinset</code> on a <rref>menuitem</rref>, <rref>menuitemcheckbox</rref>, or <rref>menuitemradio</rref>, authors SHOULD set the value of <code>aria-posinset</code> with respect to the total number of items in the <rref>menu</rref>, excluding any separators.</p>
<p>If <code>aria-posinset</code> is not specified by the author, user agents MUST compute it as defined in the <a href="#tree_groups">Calculating Group Position</a> section.</p>
Copy link
Member

@pkra pkra Jan 29, 2025

Choose a reason for hiding this comment

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

Could we replace the second sentence of the paragraph of this section with this? And then update the second paragraph similarly to my comment on aria-level?

index.html Outdated
<p>If all items up to the current item in a set are present in the document structure, it is not necessary to set this <a>attribute</a>, as the <a>user agent</a> can automatically calculate the position for these items. However, if all previous items in the set are not present in the document structure at a given moment, the author MUST set this <a>attribute</a>to provide an explicit indication of an element's position.</p>
<p>When specifying <code>aria-setsize</code>, authors MUST set the value to an integer equal to the number of items in the set. If the total number of items is unknown, authors SHOULD set the value of <code>aria-setsize</code> to <code>-1</code>.</p>
<p>When specifying <code>aria-setsize</code> on a <rref>menuitem</rref>, <rref>menuitemcheckbox</rref>, or <rref>menuitemradio</rref>, authors SHOULD set the value of <code>aria-setsize</code> based on the total number of items in the <rref>menu</rref>, excluding any separators.</p>
<p>If <code>aria-posinset</code> is not specified by the author, user agents MUST compute it as defined in the <a href="#tree_groups">Calculating Group Position</a> section.</p>
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest the same as with posinset.

Copy link
Member

Choose a reason for hiding this comment

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

Also: copy&paste error - "aria-posinset" should be "aria-setsize" here.

index.html Outdated
<h3>Calculating Group Position in the Accessibility Tree</h3>
<p>When <pref>aria-level</pref>, <pref>aria-posinset</pref>, or <pref>aria-setsize</pref> are defined on supported roles, they allow authors to override the default group position and level calculation. When those attributes are not specified by the author, user agents MUST compute them following the rules in this section.</p>

<p>If <pref>aria-level</pref> is not specified on <rref>comment</rref>, <rref>row</rref> within a <rref>treegrid</rref>, or <rref>treeitem</rref>, user agents MUST compute the level as follows:</p>
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 like listing roles but I don't see a good alternative. The best I can come up with "when not required by the role".

index.html Outdated
<li>For <pref>aria-setsize</pref>, return the total number of group items, including the current item.</li>
</ul>

<p>If the author provides one or more of <pref>aria-setsize</pref> and <pref>aria-posinset</pref>, it is the author's responsibility to supply them for all elements in the set. User agent correction of missing values in this case is not defined.</p>
Copy link
Member

Choose a reason for hiding this comment

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

"it is the author's responsibility to"

Maybe: "authors MUST"?

User agent correction of missing values in this case is not defined.

Are UAs ok with this?

index.html Outdated

<p>If the author provides one or more of <pref>aria-setsize</pref> and <pref>aria-posinset</pref>, it is the author's responsibility to supply them for all elements in the set. User agent correction of missing values in this case is not defined.</p>

<p><pref>aria-level</pref>, <pref>aria-posinset</pref>, and <pref>aria-setsize</pref> are all 1-based. When the property is not present or is "0", it indicates the property is not computed or not supported. If any of these properties are specified by the author as either "0" or a negative number, user agents SHOULD use "1" instead.</p>
Copy link
Member

Choose a reason for hiding this comment

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

The last sentence needs a change since setsize allows -1.

Copy link
Contributor

@rahimabdi rahimabdi Jul 9, 2025

Choose a reason for hiding this comment

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

@scottaohara's PR for addressing a value of -1 (indeterminate): #2341

Copy link
Member

@pkra pkra left a comment

Choose a reason for hiding this comment

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

I like the new section on calculating. I'm just not certain how to integrate it into the rest of the spec.

Reviewing this as "request changes" for just the two minor issues (the copy&paste error and the -1 issue at the very end.)

@spectranaut
Copy link
Contributor

Discussed in today's ARIA meeting: https://www.w3.org/2025/02/06-aria-minutes#3ad8

@pkra pkra force-pushed the position-required branch from f33028d to 28b4628 Compare March 17, 2025 10:54
Copy link

netlify bot commented Mar 17, 2025

Deploy Preview for wai-aria ready!

Name Link
🔨 Latest commit a7d4659
🔍 Latest deploy log https://app.netlify.com/sites/wai-aria/deploys/67d7ff9ab50e5d00087779c8
😎 Deploy Preview https://deploy-preview-2104--wai-aria.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@pkra
Copy link
Member

pkra commented Mar 17, 2025

Rebased on main.

@pkra
Copy link
Member

pkra commented Mar 17, 2025

@smhigley unfortunately, this disconnects the old comments from the lines in the rebased commit. I hope the thread is sufficient to reconstruct.

@spectranaut
Copy link
Contributor

@smhigley I think you never got to @pkra review on this is one?

and @pkra, you added agenda but then we didn't end up discussing this. Do we still need to discuss?

@pkra
Copy link
Member

pkra commented Apr 30, 2025

and @pkra, you added agenda but then we didn't end up discussing this. Do we still need to discuss?

Not from my end.

@smhigley
Copy link
Contributor Author

@rahimabdi wanted your review here to make sure this doesn't add any snags for IDL mappings (based on what was said in the call I think this may not affect IDL, but would be nice to get your review to confirm)

@spectranaut
Copy link
Contributor

Link to discussion from last weeks meeting: https://www.w3.org/2025/06/26-aria-minutes.html#b9b5

Copy link
Contributor

@rahimabdi rahimabdi left a comment

Choose a reason for hiding this comment

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

Agreed with @keithamus, I don't anticipate any IDL impact however, it does raise the question of whether ARIA should add additional numeric IDL counterparts for these attributes. Similar to the class content attribute supporting dual IDL attributes (className, classList), aria-level/aria-posinset/aria-setsize could be supplied with an additional, author-friendly IDL attribute that is truly numeric:

For example, each attribute could get a secondary IDL attribute but the original one would remain. Numeric IDL attributes also have a "default value" (similar to a missing value default) that could be specified for the numeric IDL counterparts:

  • ariaLevel
    • currently string reflects as DOMString?
    • 🆕 ariaLevelNumeric could reflect as an unsigned Long (default value = 0)
  • ariaPosInSet
    • currently string reflects as nullable DOMString?
    • 🆕 ariaPosInSetNumeric could reflect as unsigned Long (default value = 1)
  • ariaSetSize
    • currently string reflects as nullable DOMString?  
    • 🆕 ariaSetSizeNumeric could reflect as Long (default value = -1)

correction of missing values in this case is not defined.
</p>
<p>
<pref>aria-level</pref>, <pref>aria-posinset</pref>, and <pref>aria-setsize</pref> are all 1-based. When the property is not present or is "0", it indicates the property is not computed or
Copy link
Contributor

Choose a reason for hiding this comment

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

I raised a core-aam issue that this isn't necessarily the case for WebKit (for the reasons @cookiecrook mentioned on the June 26 2025 ARIA WG meeting: w3c/core-aam#249

@spectranaut spectranaut moved this from Needs Review to Needs updates from review in ARIA Normative PR Tracking Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Needs updates from review

Development

Successfully merging this pull request may close these issues.

Consider requiring user agents to calculate aria-level, aria-posinset, and aria-setsize when not declared by authors

6 participants