← Back to Pull requests

fix(label-content-name-mismatch): ignore nested widget content in visible text #5509

Open
chutchins25 opened this pull request with 423 lines diff across 5 files
View on GitHub
chutchins25 chutchins25 commented on Oct 29, 2026 17:41 UTC
Author

label-content-name-mismatch counts 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 nested role="group". This is the APG nested tree pattern, and the reported markup is:

<li role="treeitem" aria-label="Documents" aria-expanded="true">
  <span>Documents</span>
  <ul role="group">
    <li role="treeitem" aria-label="Report"><span>Report</span></li>
    <li role="treeitem" aria-label="Notes"><span>Notes</span></li>
  </ul>
</li>

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:

  • visibleVirtual gets an opt-in excludeDescendantRoleTypes option. 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.

  • The check passes a new excludeDescendantRoleTypes option, defaulting to ["widget", "composite"], documented in doc/check-options.md. Setting it to [] restores the old behavior.
  • Notes for reviewers:

  • The fix is on the visible-label side only. This rule applies only when the name comes from aria-label or aria-labelledby, so changing how names are computed from content wouldn't affect it.

  • It makes the rule a little less strict. These now pass as well: a tab with a close button, an option or gridcell containing a button, a link containing a <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-interactive already reports that markup.

  • Groups and other structure roles holding plain text still count, as does <fieldset>. <summary> maps to button, so a <details> nested inside a link loses its summary text.

  • ACT 2ee8b8 defines visible text purely by what is rendered, so this departs from it.
  • Verification:

  • New unit tests (visibleVirtual and 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.

  • New integration fixtures #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 --check and test:tsc pass. test:unit:core/commons/rule-matches/checks/api/virtual-rules/gather-internals, test:unit:integration and test:apg pass locally.

  • test:act passes apart from 78fd32 (line height), which fails the same way on develop locally and is unrelated. ACT 2ee8b8 is unchanged: 36 passing, 2 pending.
  • Closes: #5505

    Diff: 423 lines (+317 / -106) across 5 files Reviewer: straker Review duration: 50376m
    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
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    chutchins25 chutchins25
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 28.8% · Safe to merge
    28.8%