Skip to content

Add role="status" to woocommerce-info type notices #60253

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

Conversation

sunyatasattva
Copy link
Contributor

Changes proposed in this Pull Request:

In #44283, when moving new notice styles to display in block themes only, there was an oversight in removing the role="alert" for the classic info notices.

The other notices, success and error, already have role="alert" applied to them, so that was inconsistent and meant that info notices were not read by screen readers. This affected all extensions that used wc_add_notice to display info notices.

Closes #59383.

Bug introduced in PR #44283.

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Enable Back in Stock Notifications.
  2. Set a product as out of stock.
  3. Turn on a screen reader like VoiceOver or NVDA.
  4. On the shop page, find the out-of-stock product and click the Join the waitlist link.
  5. Listen as the product single loads and the notice is not read out.

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Fixed accessibility for all classic store notices added by the wc_add_notice function.

Changelog Entry Comment

Comment

In #44283, when moving new notice styles to display in block themes only,
there was an oversight in removing the `role="alert"` for the classic info notices.

The other notices, `success` and `error`, already have `role="alert"` applied to
them, so that was inconsistent and meant that `info` notices were not read by
screen readers. This affected all extensions that used `wc_add_notice` to display
info notices.
@sunyatasattva sunyatasattva self-assigned this Aug 7, 2025
@sunyatasattva sunyatasattva added the Accessibility The issue/PR is related to accessibility. label Aug 7, 2025
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Aug 7, 2025
@woocommercebot woocommercebot requested review from a team and Aljullu and removed request for a team August 7, 2025 13:46
Copy link
Contributor

github-actions bot commented Aug 7, 2025

Testing Guidelines

Hi @Aljullu ,

Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed.

Reminder: PR reviewers are required to document testing performed. This includes:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

Copy link
Contributor

coderabbitai bot commented Aug 7, 2025

📝 Walkthrough

Walkthrough

A patch was applied to WooCommerce to address accessibility issues with classic store notices generated by wc_add_notice. The WooCommerce notice template was updated to add a role="status" attribute to the notice container, ensuring that screen readers properly announce these messages. Corresponding unit tests were updated to expect this new attribute. No other functional or structural changes were made.

Changes

Cohort / File(s) Change Summary
Accessibility Patch Documentation
plugins/woocommerce/changelog/60253-wooplug-4876-accessibility-key-notices-not-being-read-by-screen-readers
Documents the patch addressing accessibility for store notices, ensuring compatibility with screen readers.
Notice Template Update
plugins/woocommerce/templates/notices/notice.php
Updates the notice template version and adds role="status" to the notice <div> for accessibility.
Unit Test Updates
plugins/woocommerce/tests/legacy/unit-tests/util/notice-functions.php
Updates test assertions to expect the new role="status" attribute on info notice containers.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c40fed8 and 5a7b98a.

📒 Files selected for processing (2)
  • plugins/woocommerce/templates/notices/notice.php (2 hunks)
  • plugins/woocommerce/tests/legacy/unit-tests/util/notice-functions.php (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • plugins/woocommerce/tests/legacy/unit-tests/util/notice-functions.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/woocommerce/templates/notices/notice.php
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wooplug-4876-accessibility-key-notices-not-being-read-by-screen-readers

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented Aug 7, 2025

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Test this pull request with WordPress Playground.

Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.

@sunyatasattva sunyatasattva changed the title Add role="alert" to woocommerce-info type notices Add role="status" to woocommerce-info type notices Aug 7, 2025
Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

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

Code changes look good and it works as described.

imatge
Testing environment
  • WordPress 6.8.2 local dev environment
  • Plugins: Back In Stock Notifications
  • Theme: TT5
  • Store creation: June 2025
  • Store size: small
  • Browser: Firefox
  • Screen reader: Orca

@sunyatasattva sunyatasattva merged commit 22fbf43 into trunk Aug 8, 2025
36 checks passed
@sunyatasattva sunyatasattva deleted the wooplug-4876-accessibility-key-notices-not-being-read-by-screen-readers branch August 8, 2025 13:35
@github-actions github-actions bot added this to the 10.2.0 milestone Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accessibility The issue/PR is related to accessibility. plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Accessibility] Key notices not being read by screen readers
2 participants