Skip to content

A11y: Improved toolbar a11y by fixing semantics #28672

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

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

mehm8128
Copy link

@mehm8128 mehm8128 commented Jul 22, 2024

Closes #25918

What I did

Grouped toolbar with labelled section.

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

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

  1. Run a sandbox for template, e.g. yarn task --task sandbox --start-from auto --template react-vite/default-ts
  2. Open Storybook in your browser
  3. Access http://localhost:6006/?path=/story/example-button--primary
  4. Check that toolbar is correctly rendered and readed by screen reader as unordered list and the section named as 'Toolbar'.

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 0 B 77.8 MB 77.8 MB - 100%
initSize 0 B 143 MB 143 MB - 100%
diffSize 0 B 65.6 MB 65.6 MB - 100%
buildSize 0 B 7.19 MB 7.19 MB - 100%
buildSbAddonsSize 0 B 1.85 MB 1.85 MB - 100%
buildSbCommonSize 0 B 195 kB 195 kB - 100%
buildSbManagerSize 0 B 1.87 MB 1.87 MB - 100%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 0 B 3.92 MB 3.92 MB - 100%
buildPreviewSize 0 B 3.28 MB 3.28 MB - 100%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 0ms 8.4s 8.4s - 100%
generateTime 0ms 25.3s 25.3s - 100%
initTime 0ms 20s 20s - 100%
buildTime 0ms 9.1s 9.1s - 100%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 0ms 6s 6s - 100%
devManagerResponsive 0ms 4.3s 4.3s - 100%
devManagerHeaderVisible 0ms 761ms 761ms - 100%
devManagerIndexVisible 0ms 790ms 790ms - 100%
devStoryVisibleUncached 0ms 2s 2s - 100%
devStoryVisible 0ms 788ms 788ms - 100%
devAutodocsVisible 0ms 636ms 636ms - 100%
devMDXVisible 0ms 702ms 702ms - 100%
buildManagerHeaderVisible 0ms 744ms 744ms - 100%
buildManagerIndexVisible 0ms 881ms 881ms - 100%
buildStoryVisible 0ms 717ms 717ms - 100%
buildAutodocsVisible 0ms 478ms 478ms - 100%
buildMDXVisible 0ms 584ms 584ms - 100%

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Improved toolbar accessibility by enhancing semantic structure and ARIA labeling.

  • code/addons/backgrounds/src/manager.tsx: Replaced Fragment with styled unordered list (ToolList) and wrapped components in list items (<li>).
  • code/core/src/manager/components/preview/Toolbar.tsx: Marked up toolbar as <section> with ARIA label and grouped tool buttons into an unordered list (<ul>).
  • code/core/src/manager/components/preview/tools/zoom.tsx: Used styled function to create ToolList component, ensuring better screen reader interpretation and visual layout.

These changes significantly improve the toolbar's accessibility but require thorough testing to avoid layout or functionality issues.

3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link
Contributor

@kasperpeulen kasperpeulen left a comment

Choose a reason for hiding this comment

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

Looks great, couple of suggestions

@kasperpeulen kasperpeulen self-assigned this Jul 22, 2024
@kasperpeulen kasperpeulen added maintenance User-facing maintenance tasks ci:normal ci:merged Run the CI jobs that normally run when merged. labels Jul 22, 2024
Copy link

nx-cloud bot commented Jul 22, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 65a6d76. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@mehm8128 mehm8128 requested a review from kasperpeulen July 22, 2024 14:53
@kasperpeulen
Copy link
Contributor

kasperpeulen commented Sep 24, 2024

Sorry, for getting back so late, could you fix the merge conflicts? @mehm8128

@mehm8128
Copy link
Author

@kasperpeulen I resolved the merge conflict. Could you review this again?

@valentinpalkovic valentinpalkovic self-assigned this Dec 24, 2024
@valentinpalkovic valentinpalkovic changed the base branch from next to next-8.5 December 24, 2024 13:59
@valentinpalkovic valentinpalkovic added accessibility and removed ci:merged Run the CI jobs that normally run when merged. labels Dec 24, 2024
@storybook-pr-benchmarking
Copy link

storybook-pr-benchmarking bot commented Dec 24, 2024

Package Benchmarks

Commit: 05846a4, ran on 16 June 2025 at 14:46:20 UTC

No significant changes detected, all good. 👏

shown={isShown}
data-test-id="sb-preview-toolbar"
>
<ScreenReaderLabel id={id}>Toolbar</ScreenReaderLabel>
Copy link
Member

Choose a reason for hiding this comment

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

@valentinpalkovic FYI I've recently added a CSS util for visually hidden content which could simplify this ScreenReaderLabel code.

Copy link
Member

Choose a reason for hiding this comment

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

See code/core/src/theming/global.ts

Comment on lines 288 to 295
const ScreenReaderLabel = styled.span({
position: 'absolute',
left: -10000,
top: 'auto',
width: 1,
height: 1,
overflow: 'hidden',
});
Copy link
Member

Choose a reason for hiding this comment

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

See sb-sr-only in code/core/src/theming/global.ts

@valentinpalkovic valentinpalkovic removed their assignment Jun 16, 2025
@valentinpalkovic
Copy link
Contributor

Hi @mehm8128

Thank you so much for your contribution so far.

We have left some comments and the PR got a bit stale. Would you be interested in continuing, resolve the merge conflicts and address the comments? Let us know whether your time allows it. Thanks!

@mehm8128 mehm8128 force-pushed the feat/improve_toolbar_a11y branch from 0a62818 to 05846a4 Compare June 16, 2025 14:33
@mehm8128
Copy link
Author

mehm8128 commented Jun 16, 2025

@valentinpalkovic
Thank you for contacting, the structure of toolbar seems to be more complex than what I have worked on before, so I'm not motivated to work on this task. So I rebased next branch and only changed toolbar HTML tag name and set visually hidden accessible name without changing toolbar items to listitem.
If it's ok to only change that, please merge this PR as is (or some fix related to the change), or can you close this PR without merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Top toolbar lacking semantics
4 participants