Skip to content

Fix technical claims of tree and treeitem roles - #45645

Merged
Josh-Cena merged 7 commits into
mdn:mainfrom
JalenBuildsHub:fix/tree-role-aria-selected-41378
Sep 29, 2026
Merged

Josh-Cena merged 7 commits into
mdn:mainfrom
JalenBuildsHub:fix/tree-role-aria-selected-41378

Conversation

@JalenBuildsHub

Copy link
Copy Markdown
Contributor

Description

Corrects the single-select tree guidance so aria-selected is true on the selected tree item, false on other selectable tree items, and omitted only from tree items that are not selectable.

Motivation

The previous wording told readers to omit aria-selected from every unselected item. That made it difficult for assistive technologies to distinguish an unselected selectable item from an item that cannot be selected.

Additional details

Validated with the target-page MarkdownLint, Prettier, front-matter, and file-check scripts under Node 24.21.0 and npm 11.19.0.

Related issues and pull requests

Fixes #41378

@JalenBuildsHub
JalenBuildsHub requested a review from a team as a code owner September 11, 2026 20:13
@JalenBuildsHub
JalenBuildsHub requested review from estelle and removed request for a team September 11, 2026 20:13
@github-actions github-actions Bot added Content:Accessibility Accessibility docs size/xs [PR only] 0-5 LoC changed labels Sep 11, 2026
Comment on lines 29 to 31
In some implementations of single-select tree, the focused item also has a selected state; this is known as "selection follows focus". When a single-select tree receives focus, if none of the tree items are selected before the tree receives focus, focus is set on the first node. If a tree item is selected before the tree receives focus, focus is set on the selected tree item. In single-select trees, [`aria-selected`](/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-selected) is set to `true` on the selected tree item and `false` on all other selectable tree items. Do not include the attribute on tree items that are not selectable.

In multi-select trees, all selected tree items have `aria-selected="true"` set and all tree item nodes that are selectable but not currently selected have `aria-selected="false"` set. Do not include the `aria-selected` attribute on tree items that are not selectable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually, these two paragraphs now look repetitive... It doesn't look like we need to differentiate between "single-select" and "multi-select" anymore; just say all selected tree items have true.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed—consolidated the attribute-value guidance into one paragraph for both modes in 1b9eb5d. It retains true for selected items, false for selectable but unselected items, and omission for non-selectable items. The selection-count and focus guidance is unchanged. The “trees that use aria-selected” qualifier avoids excluding implementations that indicate selection with aria-checked instead.

Target-page MarkdownLint, Prettier, front-matter, and filecheck all pass locally (Node 24.21.0, npm 11.19.0).

Comment thread files/en-us/web/accessibility/aria/reference/roles/tree_role/index.md Outdated
Josh-Cena
Josh-Cena previously approved these changes Sep 22, 2026

@Josh-Cena Josh-Cena left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. Thank you

@github-actions github-actions Bot added size/s [PR only] 6-50 LoC changed and removed size/xs [PR only] 0-5 LoC changed labels Sep 22, 2026
@Josh-Cena Josh-Cena changed the title Clarify aria-selected states for single-select trees Fix technical claims of tree and treeitem roles Sep 22, 2026
@github-actions github-actions Bot added size/m [PR only] 51-500 LoC changed and removed size/s [PR only] 6-50 LoC changed labels Sep 22, 2026
@Josh-Cena

Copy link
Copy Markdown
Member

@estelle This needs another look from you.

I looked around and found a bunch of technical inaccuracies for tree and treeitem, especially around hierarchy and keyboard interactions. I've aligned everything with the spec but I would need another pair of eyes.

@Josh-Cena
Josh-Cena dismissed their stale review September 22, 2026 20:12

Waiting on more review

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Preview URLs (2 pages)

(comment last updated: 2026-09-29 17:23:50)

@estelle estelle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

small nits. LGTM.

Comment thread files/en-us/web/accessibility/aria/reference/roles/tree_role/index.md Outdated
Comment thread files/en-us/web/accessibility/aria/reference/roles/tree_role/index.md Outdated
Comment thread files/en-us/web/accessibility/aria/reference/roles/treeitem_role/index.md Outdated
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
@github-actions github-actions Bot added size/l [PR only] 501-1000 LoC changed and removed size/m [PR only] 51-500 LoC changed labels Sep 29, 2026
@Josh-Cena
Josh-Cena force-pushed the fix/tree-role-aria-selected-41378 branch from b40e2b4 to cf57b55 Compare September 29, 2026 17:11
@github-actions github-actions Bot added size/m [PR only] 51-500 LoC changed and removed size/l [PR only] 501-1000 LoC changed labels Sep 29, 2026
Comment thread files/en-us/web/accessibility/aria/reference/roles/treeitem_role/index.md Outdated
@Josh-Cena
Josh-Cena force-pushed the fix/tree-role-aria-selected-41378 branch from cf57b55 to 2158ecf Compare September 29, 2026 17:16
@Josh-Cena
Josh-Cena merged commit 9abb432 into mdn:main Sep 29, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:Accessibility Accessibility docs size/m [PR only] 51-500 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

role="tree": aria-selected is required for selectable items

4 participants