Add ARIA attributes to ProgressBar component #1271
Open
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.
Add ARIA attributes to ProgressBar component
Summary
This PR adds ARIA attributes (
aria-valuemin,aria-valuemax, andaria-valuenow) to the ProgressBar component to improve accessibility for screen reader users. This addresses the TODO comment on line 115 ofsrc/components/ProgressBar.tsx.Issue Fixed
Resolves the TODO comment requesting ARIA attributes for the progress bar:
// TODO: add aria-valuenow, aria-valuemax, aria-valueminRoot Cause
The ProgressBar component was missing essential ARIA attributes that allow screen readers to properly announce the progress state to users with visual impairments. While the component had
role="progressbar"andaria-label, it lacked the value attributes that provide specific progress information.Solution Details
Implementation
Added ARIA attributes object with:
aria-valuemin: Always set to0(minimum progress)aria-valuemax: Always set to1(maximum progress)aria-valuenow: Conditionally set for controlled progress bars onlyConditional
aria-valuenow:controlledProgressistrueandprogressis a numberMath.max(0, Math.min(1, progress))Type safety: Added proper TypeScript typing for the ARIA attributes object
Files Changed
src/components/ProgressBar.tsx: Added ARIA attributes implementationsrc/components/ProgressBar.cy.tsx: Added comprehensive tests for ARIA attributesBefore vs After Behavior
Before
Screen reader experience: Screen readers could identify the element as a progress bar but couldn't announce the current progress value or range.
After
Screen reader experience: Screen readers can now announce:
TypeScript Type Impact
No breaking changes to existing types. The change is purely additive:
ProgressBarPropsinterfaceTests
New Tests Added
has ARIA attributes for accessibility: Verifies that animated progress bars havearia-valueminandaria-valuemax, but notaria-valuenowhas aria-valuenow for controlled progress bar: Verifies that controlled progress bars include all three ARIA attributes with correct valuesclamps aria-valuenow between 0 and 1: Ensures that out-of-range progress values are properly clampedTest Coverage
aria-valuenow)aria-valuenow)Preview Steps
Test with screen reader:
Verify in browser DevTools:
aria-valuemin,aria-valuemax, and (conditionally)aria-valuenowattributesRun accessibility audit:
Justification for Merge
✅ Addresses Explicit TODO
The codebase has a clear TODO comment requesting this feature, indicating it's a known improvement needed.
✅ Accessibility Improvement
✅ Non-Breaking Change
✅ Small, Focused Scope
✅ Well-Tested
✅ Follows Project Conventions
✅ High Merge Potential
Related Resources