feat: add accessibilityLabel support to UI components#11
Conversation
- Button: use text as default accessibilityLabel, add accessibilityRole="button" - IconButton: use icon name as default accessibilityLabel - Checkbox: use text as default, add accessibilityState (checked, disabled) - SwitchToggle: add accessibilityState (checked) - EditText: use label or placeholder as default accessibilityLabel - RadioButton: use label as default, add accessibilityState (selected, disabled) - SegmentedControl: use segment text as accessibilityLabel All components allow custom accessibilityLabel via props for customization. Added comprehensive accessibility tests for all modified components. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR adds comprehensive accessibility support across multiple UI components. Each component now accepts an optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Visit the preview URL for this PR (updated for commit d5e898c): https://cpk-ui--pr11-feat-accessibility-l-3a57hpq8.web.app (expires Sun, 25 Jan 2026 09:05:23 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 05244aa8e2a82af676f8a528c78a4bcd59756f99 |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/uis/IconButton/IconButton.tsx (1)
212-222: Default accessibilityLabel is missing wheniconis omitted.
Ificonis undefined, the component renders the fallback icon but the label becomes undefined. Consider aligning the label with the rendered icon unless a customiconElementis supplied.🛠️ Proposed fix
- const IconView = useMemo(() => - iconElement || ( - <Icon - color={buttonStylesConfig.iconColor} - name={icon || 'QuestBoxFill'} - size={iconSize} - style={compositeStyles?.icon} - /> - ), - [iconElement, buttonStylesConfig.iconColor, icon, iconSize, compositeStyles?.icon] - ); + const resolvedIconName = icon ?? 'QuestBoxFill'; + const IconView = useMemo(() => + iconElement || ( + <Icon + color={buttonStylesConfig.iconColor} + name={resolvedIconName} + size={iconSize} + style={compositeStyles?.icon} + /> + ), + [iconElement, buttonStylesConfig.iconColor, resolvedIconName, iconSize, compositeStyles?.icon] + ); ... - accessibilityLabel={accessibilityLabel ?? icon} + accessibilityLabel={ + accessibilityLabel ?? (iconElement ? undefined : resolvedIconName) + }Also applies to: 249-252
🧹 Nitpick comments (1)
src/components/uis/SegmentedControl/SegmentedControl.tsx (1)
169-175: Include disabled in accessibilityState when SegmentedControl is disabled.Line 174 only reports
selected. Screen readers often rely onaccessibilityState.disabledrather than thedisabledprop alone. Consider addingdisabledto the state.♻️ Proposed tweak
- accessibilityState={{selected: isSelected}} + accessibilityState={{selected: isSelected, disabled}}
Summary
accessibilityLabelprop to all interactive UI componentsaccessibilityRoleandaccessibilityStatefor better screen reader supportComponents
Button, IconButton, Checkbox, SwitchToggle, EditText, RadioButton, SegmentedControl
Test
Added accessibility tests for all modified components
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.