Repository navigation
fix: exclude group/menu descendants from treeitem/menuitem name-from-content - #1101
Open
ArmandRedgate wants to merge 1 commit into
Open
ArmandRedgate wants to merge 1 commit into
ArmandRedgate wants to merge 1 commit into
Conversation
…content Per the WAI-ARIA APG (https://www.w3.org/WAI/ARIA/apg/practices/names-and-descriptions/#naming_with_child_content): "When calculating a name from content for the treeitem role, descendant content of child group elements are not included [...] a menuitem role with a menu descendant [...] is a similar case." computeMiscTextAlternative previously recursed into every child node unconditionally, so an expanded treeitem's accessible name incorrectly concatenated the labels of its nested treeitem children (and similarly for menuitem/menu). Real browsers correctly exclude these descendants; this brings the library's computation in line with both the spec and observed browser behavior. Fixes eps1lon#1100 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Created with help from Claude (I am not familiar with this codebase, I will admit). Code seems reasonable on self-review and existing and new tests pass.
Summary
Fixes #1100.
Per the WAI-ARIA APG:
computeMiscTextAlternativepreviously recursed into every child node unconditionally when computing name-from-content, so an expandedtreeitem's accessible name incorrectly concatenated the labels of its nestedtreeitemchildren (and similarly formenuitem/menu). Real browsers (confirmed via Chrome DevTools' accessibility tree) correctly exclude these descendants - this brings the computation in line with both the spec note and observed browser behavior.Changes
sources/accessible-name-and-description.ts: addedisExcludedFromNameFromContent, applied as a filter overchildNodesincomputeMiscTextAlternativebefore recursing.sources/__tests__/accessible-name.js: added coverage for thetreeitem/groupcase (using the spec's own Fruits/Apples/Bananas/Oranges example), the analogousmenuitem/menucase, and a control case confirming an unrelated role (button) with agroupdescendant is unaffected..changeset/tricky-buttons-fly.md: changeset entry.Test plan
yarn test- all 777 tests pass (768 existing + 9 new, across jsdom/mock-edge14/mock-ie11 projects)yarn test:types- passesyarn lint- passes