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

[TreeView] Fix usage of the aria-selected attribute #14991

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Oct 16, 2024

Fixes #14982

The old behavior was linking to the ARIA doc which does not describes what was implemented...

Preview: https://deploy-preview-14991--material-ui-x.netlify.app/x/react-tree-view/simple-tree-view/selection/

@flaviendelangle flaviendelangle added accessibility a11y component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! labels Oct 16, 2024
@flaviendelangle flaviendelangle self-assigned this Oct 16, 2024
@mui-bot
Copy link

mui-bot commented Oct 16, 2024

Deploy preview: https://deploy-preview-14991--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 5cf3aea

@LukasTy LukasTy added the enhancement This is not a bug, nor a new feature label Oct 16, 2024
Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

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

LGTM, nice improvement! 👍 👏

@flaviendelangle flaviendelangle merged commit 19d2255 into mui:master Oct 16, 2024
24 checks passed
@flaviendelangle flaviendelangle deleted the aria-selected branch October 16, 2024 07:50
ariaSelected = true;
} else if (disableSelection || disabled) {
// - if the tree contains nodes that are not selectable, aria-selected is not present on those nodes.
ariaSelected = undefined;
Copy link
Member

Choose a reason for hiding this comment

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

They mentioned that "without the aria-selected=“false”, NVDA doesn't render the information, so we don't know if the item is selected or not."
I'm not sure if NVDA does that only when there's at least one selected, but I'm wondering if, in order to "display" the items, it should always be false even when there's no selection or selection is disabled.

Copy link
Member

Choose a reason for hiding this comment

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

https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-selected states for Grid that setting aria-selected="false" on a focusable gridcell indicates the cell is selectable.
I believe the same logic applies to Tree items, so ariaSelected=undefined is the way to go indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[tree view] All selectable items should have aria-selected set to false when they are not selected
4 participants