fix(select): add accessibility labels to scroll buttons #8828
+58
−3
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.
Summary
This pull request adds screen reader labels to the
SelectScrollUpButtonandSelectScrollDownButtoncomponents in the Select component. These buttons currently only display visual icons (chevrons) without accessible text labels, which creates a poor experience for users relying on screen readers.Motivation
Accessibility is a core principle of shadcn/ui. The Select component's scroll buttons are interactive elements that should be properly labeled for assistive technologies. Currently, screen reader users cannot understand the purpose of these buttons when navigating the Select dropdown, as they only contain visual icons without descriptive text.
This fix ensures compliance with WCAG 2.1 accessibility guidelines (specifically Success Criterion 4.1.2 - Name, Role, Value) by providing accessible names for all interactive elements.
Changes
Files Modified
apps/v4/registry/new-york-v4/ui/select.tsx<span className="sr-only">Scroll up</span>toSelectScrollUpButton<span className="sr-only">Scroll down</span>toSelectScrollDownButtonWhy
The
sr-onlyclass (screen reader only) is a standard Tailwind CSS utility that visually hides content while keeping it available to screen readers. This pattern is already used throughout the shadcn/ui codebase (e.g., in Dialog close button, Sheet close button, Pagination, etc.) for consistent accessibility practices.Before vs After Behavior
Before:
After:
Screenshots
No visual changes - the fix only affects screen reader announcements.
Potential Risks / Breaking Changes
None. This is a non-breaking change that:
Checklist
Testing
Manual Testing
Automated Testing
Unit tests have been added to verify the presence of
sr-onlylabels in the scroll button components.Additional Notes
This fix aligns with shadcn/ui's commitment to accessibility and follows the same pattern used in other components like:
Dialogcomponent's close buttonSheetcomponent's close buttonPaginationcomponent's navigation buttonsCarouselcomponent's navigation buttonsThe implementation is minimal, focused, and maintains consistency with the existing codebase architecture.