fix(label-content-name-mismatch): ignore nested widget content in visible text #5509
All Vouch review confidence checks passed
Residual risk 0.29 = Change Risk (0.52) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 423 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.362
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #5509"
general
weight: 0.35
straker
chutchins25
label-content-name-mismatchcounts every visible descendant as part of an element's visible label. For an expanded tree item, that includes the text of the child items in its nestedrole="group". This is the APG nested tree pattern, and the reported markup is:The parent's visible text came out as
Documents Report Notes, so every expanded parent item was reported as a violation now that the rule is on by default. The child items pass.A nested widget is its own control with its own name, so its text isn't part of the outer element's label. As agreed on #5505, this PR leaves the content of nested widgets out of the visible label:
visibleVirtualgets an opt-inexcludeDescendantRoleTypesoption. It applies only when the element itself has one of the listed role types. A descendant whose role (with fallback roles) has one of the listed role types is not walked. When displayed it counts as a single space, so the words on either side of it stay apart; when hidden it adds nothing. The element itself is never excluded. No other caller passes the option, so their output is unchanged.excludeDescendantRoleTypesoption, defaulting to["widget", "composite"], documented indoc/check-options.md. Setting it to[]restores the old behavior.Notes for reviewers:
aria-labeloraria-labelledby, so changing how names are computed from content wouldn't affect it.<select>, a menu item with an open submenu, and an element whose only visible text is inside a nested widget. A nested control inside an element with presentational children (a button inside a button) is not special-cased;nested-interactivealready reports that markup.<fieldset>.<summary>maps tobutton, so a<details>nested inside a link loses its summary text.Verification:
visibleVirtualand the check) fail without the change and pass with it, including guards that a leaf tree item's own text, and a nested group holding plain text, still count. Disabling the exclusion turns 12 of the new tests red.#pass21(the reported tree item, cut down) and#pass22(a menu item with an open submenu) pass, and both fail with the exclusion disabled.#fail11, a leaf tree item whose text isn't in its name, still fails.eslint,prettier --checkandtest:tscpass.test:unit:core/commons/rule-matches/checks/api/virtual-rules/gather-internals,test:unit:integrationandtest:apgpass locally.test:actpasses apart from 78fd32 (line height), which fails the same way ondeveloplocally and is unrelated. ACT 2ee8b8 is unchanged: 36 passing, 2 pending.Closes: #5505