Skip to content

Docs: Add ariaLabel support to ActionItem interface#34749

Merged
Sidnioulz merged 2 commits into
storybookjs:nextfrom
TheSeydiCharyyev:fix/issue-34746-action-item-aria-label
May 21, 2026
Merged

Docs: Add ariaLabel support to ActionItem interface#34749
Sidnioulz merged 2 commits into
storybookjs:nextfrom
TheSeydiCharyyev:fix/issue-34746-action-item-aria-label

Conversation

@TheSeydiCharyyev
Copy link
Copy Markdown
Contributor

@TheSeydiCharyyev TheSeydiCharyyev commented May 8, 2026

Closes #34746

What I did

Added ariaLabel?: string to the ActionItem interface so users can supply a custom accessible label for buttons rendered via canvas.additionalActions in the docs addon.

  • Added ariaLabel?: string to ActionItem in code/core/src/components/components/ActionBar/ActionBar.tsx
  • Synced the duplicate inline type in code/addons/docs/src/types.ts
  • Passed ariaLabel to <Button> in Preview.tsx with ariaLabel ?? false as default — false suppresses the Storybook 11 mandatory-prop warning when title is visible text, while a custom ariaLabel is used when provided

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

I did not add automated tests because the change is a TypeScript type addition plus a prop pass-through. Happy to add a story with a play function asserting aria-label if preferred.

Manual testing

  1. cd code && yarn storybook:ui
  2. Open addons/docs/blocks/components/PreviewWith Additional Actions
  3. Open the browser Console — the 'ariaLabel' prop on 'Button' will become mandatory in Storybook 11 warning is no longer emitted from the additional action buttons
  4. Optionally, pass ariaLabel in additionalActions via the docs canvas parameter to confirm a custom label is forwarded to the rendered button

Documentation

  • Add or update documentation reflecting your changes
  • If deprecating/removing a feature, update MIGRATION.md

Checklist for Maintainers

  • Add ci:normal, ci:merged or ci:daily label to run sandboxes
  • Add one label: bug, maintenance, dependencies, build, cleanup, documentation, feature request, BREAKING CHANGE, other

Canary release

This PR does not have a canary release associated. Request by mentioning @storybookjs/core team.


AI tool: I used Claude Code for analysis. The implementation and testing was done by me.

Summary by CodeRabbit

  • New Features
    • Action buttons now support accessible aria-labels, improving screen reader announcements and keyboard/assistive-tool interaction for custom actions.
    • Preview and action bar controls consistently expose these accessible labels, ensuring clearer, more usable controls for users relying on assistive technologies.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0c20e944-7191-4705-ade7-93481f2a7c7b

📥 Commits

Reviewing files that changed from the base of the PR and between 5317bfc and a856c2c.

📒 Files selected for processing (3)
  • code/addons/docs/src/blocks/components/Preview.tsx
  • code/addons/docs/src/types.ts
  • code/core/src/components/components/ActionBar/ActionBar.tsx

📝 Walkthrough

Walkthrough

Adds optional ariaLabel to action item types and forwards it to rendered buttons in ActionBar and Preview for accessible labeling.

Changes

Action Item aria-label Support

Layer / File(s) Summary
Core Type Contract
code/core/src/components/components/ActionBar/ActionBar.tsx
ActionItem interface adds optional ariaLabel?: string property for accessible button labeling.
ActionBar Rendering
code/core/src/components/components/ActionBar/ActionBar.tsx
ActionBar mapping now destructures ariaLabel and passes it to ActionButton as aria-label.
Docs Type Extension
code/addons/docs/src/types.ts
CanvasBlockParameters.additionalActions action items now include optional ariaLabel field for docs canvas configuration.
Preview Implementation
code/addons/docs/src/blocks/components/Preview.tsx
Preview component destructures ariaLabel from each additional action and applies it to Button components.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Preview
  participant ActionBar
  participant Button
  User->>Preview: interacts with preview UI
  Preview->>ActionBar: provides additionalActions (includes ariaLabel)
  ActionBar->>Button: render button with aria-label and handlers
  Button-->>User: accessible button rendered
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
code/core/src/components/components/ActionBar/ActionBar.tsx (1)

90-100: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

ariaLabel is declared in ActionItem but never forwarded to ActionButton.

Line 93 destructures title, className, onClick, and disabledariaLabel is omitted. ActionButton therefore never receives an aria-label attribute, making the interface addition a silent no-op for any direct consumer of ActionBar.

🛠️ Proposed fix
- {actionItems.map(({ title, className, onClick, disabled }, index: number) => (
-   <ActionButton key={index} className={className} onClick={onClick} disabled={!!disabled}>
+ {actionItems.map(({ title, ariaLabel, className, onClick, disabled }, index: number) => (
+   <ActionButton key={index} aria-label={ariaLabel} className={className} onClick={onClick} disabled={!!disabled}>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@code/core/src/components/components/ActionBar/ActionBar.tsx` around lines 90
- 100, The ActionBar currently destructures title, className, onClick, and
disabled from each ActionItem but omits ariaLabel so ActionButton never receives
an aria-label; update the mapping in ActionBar to also destructure ariaLabel
(from actionItems) and pass it through to ActionButton (e.g., <ActionButton ...
aria-label={ariaLabel} />) so the ActionButton receives the accessibility
attribute for each ActionItem.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@code/core/src/components/components/ActionBar/ActionBar.tsx`:
- Around line 90-100: The ActionBar currently destructures title, className,
onClick, and disabled from each ActionItem but omits ariaLabel so ActionButton
never receives an aria-label; update the mapping in ActionBar to also
destructure ariaLabel (from actionItems) and pass it through to ActionButton
(e.g., <ActionButton ... aria-label={ariaLabel} />) so the ActionButton receives
the accessibility attribute for each ActionItem.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b958c7c3-109e-4864-b46d-f6f3dfd5ce5a

📥 Commits

Reviewing files that changed from the base of the PR and between 245043f and 6d2d766.

📒 Files selected for processing (3)
  • code/addons/docs/src/blocks/components/Preview.tsx
  • code/addons/docs/src/types.ts
  • code/core/src/components/components/ActionBar/ActionBar.tsx

- Add ariaLabel?: string to ActionItem in ActionBar.tsx

- Sync the duplicate inline type in addons/docs/src/types.ts

- Pass ariaLabel through to Button in Preview.tsx (defaults to false to suppress the mandatory-prop warning when title is visible)

Closes storybookjs#34746
Addresses CodeRabbit review feedback. ActionBar.tsx now destructures ariaLabel and passes it as aria-label HTML attribute, so ActionItem.ariaLabel is honored when ActionBar is used directly (not only via Preview.tsx).
@Sidnioulz Sidnioulz force-pushed the fix/issue-34746-action-item-aria-label branch from 1f0e895 to a856c2c Compare May 21, 2026 09:09
@Sidnioulz Sidnioulz merged commit 5bbca13 into storybookjs:next May 21, 2026
136 of 142 checks passed
@github-project-automation github-project-automation Bot moved this from Empathy Queue (prioritized) to Done in Core Team Projects May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: ActionItem interface doesn't support ariaLabel property in Storybook 10

3 participants