-
Notifications
You must be signed in to change notification settings - Fork 0
🎨 Palette: Add ARIA progressbar roles to Progress component #959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { describe, it, expect } from 'vitest'; | ||
| import { Progress } from './progress'; | ||
|
|
||
| describe('Progress Component', () => { | ||
| it('renders correctly with default values', () => { | ||
| render(<Progress />); | ||
| const progressbar = screen.getByRole('progressbar'); | ||
| expect(progressbar).toBeInTheDocument(); | ||
| expect(progressbar).toHaveAttribute('aria-valuemin', '0'); | ||
| expect(progressbar).toHaveAttribute('aria-valuemax', '100'); | ||
| expect(progressbar).toHaveAttribute('aria-valuenow', '0'); | ||
| }); | ||
|
|
||
| it('renders correctly with custom value and max', () => { | ||
| render(<Progress value={50} max={200} />); | ||
| const progressbar = screen.getByRole('progressbar'); | ||
| expect(progressbar).toHaveAttribute('aria-valuenow', '50'); | ||
| expect(progressbar).toHaveAttribute('aria-valuemax', '200'); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,10 @@ export const Progress: React.FC<ProgressProps> = ({ | |
|
|
||
| return ( | ||
| <div | ||
| role="progressbar" | ||
| aria-valuemin={0} | ||
| aria-valuemax={max} | ||
| aria-valuenow={value} | ||
| className={`relative w-full overflow-hidden rounded-full bg-gray-200 ${className}`} | ||
|
Comment on lines
+18
to
22
|
||
| {...props} | ||
| > | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new tests assert the presence of ARIA attributes for default/custom cases, but they don't cover the out-of-range scenarios where the component currently clamps the visual fill. Adding tests for
value > maxandvalue < 0would prevent regressions and ensure ARIA values stay consistent with the rendered progress.