Skip to content

Improve Toast accessibility and clean up stories#22978

Merged
vraja-pro merged 3 commits intotrunkfrom
jordi-pv/improve-toast-focus-managment
Feb 20, 2026
Merged

Improve Toast accessibility and clean up stories#22978
vraja-pro merged 3 commits intotrunkfrom
jordi-pv/improve-toast-focus-managment

Conversation

@JorPV
Copy link
Copy Markdown
Contributor

@JorPV JorPV commented Feb 13, 2026

Context

  • The Toast component's Close button used a sr-only span for its accessible label, which is less robust than using aria-label. Additionally, the Complex layout story demonstrated interactive patterns (confirm/dismiss buttons) that contradict the Toast's purpose as a non-interactive, informational component.

Summary

This PR can be summarized in the following changelog entry:

  • [@yoast/ui-library 0.0.1 enhancement] Improves Toast component accessibility and documentation.

Relevant technical choices:

  • Close button accessibility: Replaced sr-only span with aria-label on the button and added aria-hidden="true" on the XIcon. This is more robust and follows the standard pattern for icon-only buttons.
  • Removed Complex layout story: The story demonstrated interactive patterns (confirm/dismiss actions) that belong in ModalNotification, not in the non-modal Toast.
  • Updated docs: Clarified that toasts are non-interactive and informational. The Toast.Close docs now recommend using ModalNotification for interactive notifications.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  1. Run the UI Library Storybook (yarn workspace @yoast/ui-library storybook).
  2. Go to "1) Elements/Toast" in the Storybook sidebar.
  3. Verify the "Complex layout" story is no longer present.
  4. Open the "With close button" story:
    • Click "Toggle toast" to show the toast.
    • Inspect the close button — it should have aria-label="Dismiss" and the XIcon should have aria-hidden="true".
    • Verify the close button still works.
  5. Check the Docs page — the Toast.Close documentation should mention that toasts are non-interactive and recommend ModalNotification for interactive use cases.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Check the console for any React warnings or errors.

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • The Toast.Close sub-component — any place in the plugin that uses Toast.Close should still work correctly (only the accessible label implementation changed, not the behavior).

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.
  • This PR also affects Yoast SEO for Google Docs. I have added a changelog entry starting with [yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached the Google Docs Add-on label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.
  • I have run grunt build:images and commited the results, if my PR introduces new images or SVGs.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes #1037

@JorPV JorPV requested a review from a team as a code owner February 13, 2026 16:13
@JorPV JorPV added the changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog label Feb 13, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented Feb 13, 2026

Pull Request Test Coverage Report for Build 501b17bb426179b3391e988460284e2d027dde5d

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 56.324%

Totals Coverage Status
Change from base Build f7234012bdf13a247018eec69d26e603a07a5027: 0.0%
Covered Lines: 14988
Relevant Lines: 25953

💛 - Coveralls

>
<span className="yst-sr-only">{ dismissScreenReaderLabel }</span>
<XIcon className="yst-h-5 yst-w-5" />
<XIcon className="yst-h-5 yst-w-5" aria-hidden="true" />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually we can use here the hook useSvgAria to get the svg props which includes the aria-hidden. We should also fix that in packages/ui-library/src/elements/modal-notification/index.js.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. I'll implement it

Copy link
Copy Markdown
Contributor

@vraja-pro vraja-pro left a comment

Choose a reason for hiding this comment

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

CR 🚧

… Toast components to enhance accessibility features.
@vraja-pro vraja-pro added this to the 27.2 milestone Feb 20, 2026
Copy link
Copy Markdown
Contributor

@vraja-pro vraja-pro left a comment

Choose a reason for hiding this comment

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

CR & AC ✅

@vraja-pro vraja-pro merged commit 8743d50 into trunk Feb 20, 2026
20 checks passed
@vraja-pro vraja-pro deleted the jordi-pv/improve-toast-focus-managment branch February 20, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants