Skip to content

feat: Extract component description from aria-describedby#220

Merged
gethinwebster merged 1 commit into
mainfrom
dev-v3-gethinw-extract-description
Jun 1, 2026
Merged

feat: Extract component description from aria-describedby#220
gethinwebster merged 1 commit into
mainfrom
dev-v3-gethinw-extract-description

Conversation

@gethinwebster

@gethinwebster gethinwebster commented May 27, 2026

Copy link
Copy Markdown
Member

Description

Adds a description field to the component metadata tree output. The description is extracted by resolving aria-describedby on the same element used for label resolution (found via the component's label selector). All space-separated IDs are resolved and their text content concatenated, matching screen reader behavior.

This works because aria-labelledby and aria-describedby are always placed on the same interactive control element in Cloudscape components. FormField is correctly excluded since its label selector points to a <label> element which does not have aria-describedby.

Example output

For an Input inside a FormField with constraintText="Must be 3-20 characters":

{
  "name": "awsui.Input",
  "label": "Username",
  "description": "Must be 3-20 characters",
  "properties": { "value": "..." }
}

Changes

  • Added description?: string to GeneratedAnalyticsMetadataComponentTree interface
  • Added resolveComponentDescription helper that uses the label selector to find the element, checks aria-describedby, and concatenates all referenced IDs' text content. Iterates through array selectors (like label resolution) returning the first match.
  • Integrated into processMetadata: description is extracted when a component has name and a label selector defined
  • 7 new unit tests covering: basic extraction, multi-ID concatenation, no describedby, no label selector, label element without describedby, missing IDs, array selector fallback

Testing

All 412 unit tests pass.

Components unit tests in dry run expected to fail because 1) of as-yet in-pipeline diffs from a previous PR, 2) expected diffs from this PR (description now provided in some of the test cases)

@gethinwebster gethinwebster force-pushed the dev-v3-gethinw-extract-description branch from 3b89535 to c2665f9 Compare May 27, 2026 13:40
@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.99%. Comparing base (eb4fa98) to head (fae39d1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #220      +/-   ##
==========================================
+ Coverage   98.97%   98.99%   +0.01%     
==========================================
  Files          44       44              
  Lines        1272     1293      +21     
  Branches      351      337      -14     
==========================================
+ Hits         1259     1280      +21     
- Misses         12       13       +1     
+ Partials        1        0       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gethinwebster gethinwebster force-pushed the dev-v3-gethinw-extract-description branch 5 times, most recently from 44e36e4 to 0643df9 Compare May 28, 2026 12:49
Add description field to component metadata tree output. When a
component has a label extracted, the toolkit now also resolves
aria-describedby on the first child element that has it, concatenating
all referenced IDs' text content (matching screen reader behavior).

This enables consumers like the page scanner to access constraint text,
descriptions, and other accessible descriptions alongside labels.
@gethinwebster gethinwebster force-pushed the dev-v3-gethinw-extract-description branch from 0643df9 to fae39d1 Compare May 28, 2026 12:53
@gethinwebster gethinwebster marked this pull request as ready for review May 28, 2026 13:40
@gethinwebster gethinwebster requested a review from a team as a code owner May 28, 2026 13:40
@gethinwebster gethinwebster requested review from amanabiy and removed request for a team May 28, 2026 13:40
@gethinwebster gethinwebster added this pull request to the merge queue Jun 1, 2026
Merged via the queue into main with commit 3ff2844 Jun 1, 2026
122 of 126 checks passed
@gethinwebster gethinwebster deleted the dev-v3-gethinw-extract-description branch June 1, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants