CODAP-575: add aria-label to tool shelf and inspector panel buttons#2433
CODAP-575: add aria-label to tool shelf and inspector panel buttons#2433
Conversation
Add aria-label attributes to all toolbar buttons (Tables, Graph, Map, Slider, Calc, Text, Plugins, Undo, Redo, Tiles, Guide) and all inspector panel buttons (InspectorButton and InspectorMenu) across all tile types. For icon-only buttons (e.g. text inspector), the tooltip is used as the aria-label with parenthetical keyboard shortcuts stripped to keep screen reader announcements clean. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2433 +/- ##
===========================================
- Coverage 85.51% 69.27% -16.25%
===========================================
Files 758 758
Lines 42137 42140 +3
Branches 10428 10342 -86
===========================================
- Hits 36034 29193 -6841
- Misses 6088 12922 +6834
- Partials 15 25 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR improves accessibility by adding explicit aria-label attributes to tool shelf and inspector panel buttons so screen readers can announce meaningful names (especially for icon-only controls).
Changes:
- Add
aria-labelto the genericToolShelfButtonand to several menu-style tool shelf buttons (tiles list, plugins, guide, case table). - Add
aria-labelsupport toInspectorButtonandInspectorMenu, including cleanup of tooltip-derived labels by stripping trailing parenthetical shortcuts.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| v3/src/components/tool-shelf/tool-shelf-button.tsx | Adds aria-label to the base tool shelf button component. |
| v3/src/components/tool-shelf/tiles-list-button.tsx | Adds aria-label to the tiles list menu button. |
| v3/src/components/tool-shelf/plugins-button.tsx | Adds aria-label to the plugins menu button. |
| v3/src/components/tool-shelf/guide-button.tsx | Adds aria-label to the guide menu button. |
| v3/src/components/inspector-panel.tsx | Adds aria-label to inspector buttons/menus; strips trailing shortcut text from tooltip-based labels. |
| v3/src/components/case-table/case-table-tool-shelf-button.tsx | Adds aria-label to the case table menu button. |
Comments suppressed due to low confidence (1)
v3/src/components/tool-shelf/tool-shelf-button.tsx:33
ToolShelfButtonreceiveslabel/hintas already-translated UI strings (e.g.label={t(labelKey)}intool-shelf.tsx). Callingt(label)/t(hint)again foraria-label/titleis redundant and can produce incorrect output if the translated string happens to match another translation key. Use thelabel/hintprops directly foraria-labelandtitle(and consider doing the same forToolShelfButtonTag).
as='button'
aria-label={t(label)}
title={t(hint)}
disabled={disabled}
onClick={onClick}
data-testid={`tool-shelf-button-${label.toLowerCase()}`}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
codap-v3
|
||||||||||||||||||||||||||||
| Project |
codap-v3
|
| Branch Review |
main
|
| Run status |
|
| Run duration | 02m 19s |
| Commit |
|
| Committer | github-actions[bot] |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
4
|
| View all changes introduced in this branch ↗︎ | |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
While these changes generally look OK and should technically work OK, I don't think adding aria-label for buttons that contain text, and setting that aria-label value to the same value is the right thing to do. My understanding is that unless a button contains no text or there's a need to provide a label that differs from the text it contains, there's no reason for adding aria-label. And generally, unnecessary use of ARIA is discouraged: The First Rule of ARIA Use
It does make sense to add aria-label for buttons that don't have text (like those that don't have a defined label value in inspector-panel.tsx) or have text that we want to adjust for screen readers (like where you're stripping the keyboard shortcuts).
From developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label
"By default, a button's accessible name is the content between the opening and closing tags."
These buttons do contain other elements besides the text, but they're (at least currently) "invisible" to screen readers because they don't have alt attributes. So just the button text will be used as the label. One way to check that is to inspect the button in Chrome's Dev Tools and view the Accessibility tab. The "Name" value is the label. If you do that on the main branch you'll see "Table" for the Table button, for example, even though there's no aria-label used there.
So, I would suggest removing aria-label wherever it's clearly redundant. Again, it's probably OK as-is, but I still don't think it's the right thing to do. If you have a counter argument, I'm open to hearing it, though.
I asked Claude about this. The problem is how one interprets "clearly redundant". None of the usages here are |
Accessibility Audit: aria-label Redundancy AnalysisI ran a thorough accessibility audit on these changes, tracing through Chakra UI's internal rendering to understand the actual DOM structure and accessible name computation. Here's the summary: Necessary — must keepInspectorButton (icon-only) and InspectorMenu (icon-only) — e.g. the text formatting buttons (bold, italic, underline, etc.). These have no visible text at all. Without Redundant but harmlessAll tool shelf buttons (ToolShelfButton, CaseTableToolShelfButton, GuideButton, PluginsButton, TilesListShelfButton) and InspectorButton/InspectorMenu when a These buttons all render visible text via Since the The reviewer's concern is technically correct — these Minor suggestion
|
…ctor inspector aria-label logic Tool shelf buttons already have visible text labels that screen readers can compute as accessible names, so explicit aria-labels are unnecessary. Inspector panel buttons use a shared ariaLabel() helper that returns undefined for labeled buttons and a shortcut-stripped tooltip for icon-only buttons. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Addressed in the latest commit. |
Thanks 👍 I think that's better, though I do understand it's open to interpretation. |
emcelroy
left a comment
There was a problem hiding this comment.
Looks good 👍
For the record, I wouldn't be totally opposed to using aria-label for all the buttons, and think it's reasonable to at least consider it. I always remember that First Rule of ARIA, though, and tend to think it's best not to use it unless it's necessary.
Summary
Addaria-labelto all toolbar buttons (Tables, Graph, Map, Slider, Calc, Text, Plugins, Undo, Redo, Tiles, Guide)Addaria-labeltoInspectorButtonandInspectorMenucomponents, covering all tile inspector panelsFixes CODAP-575
Test plan
aria-labelin browser dev toolsaria-label🤖 Generated with Claude Code