Skip to content

Announce settings save status to screen readers - #1851

Open
benitoalba wants to merge 2 commits into
equalizedigital:developfrom
benitoalba:fix/1757-announce-settings-save-status
Open

Announce settings save status to screen readers#1851
benitoalba wants to merge 2 commits into
equalizedigital:developfrom
benitoalba:fix/1757-announce-settings-save-status

Conversation

@benitoalba

@benitoalba benitoalba commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1757.

  • Render WordPress Settings API feedback on the Accessibility Checker settings page.
  • Announce the saved result through wp.a11y.speak, using polite output for success and assertive output for errors.
  • Declare wp-a11y as a dependency of the admin bundle.
  • Add focused PHPUnit and Jest regression coverage.

Root cause

The settings form submits through WordPress's Settings API, which stores the standard result notice, but the custom settings page did not call settings_errors(). The page therefore refreshed without showing or announcing the save result.

The settings page now renders the standard visible notice immediately after its heading. On DOM ready, the admin bundle detects the notice and schedules the announcement for one second after the page finishes loading. This prevents the polite status from being lost among the screen reader's page-load announcements and does not move keyboard focus.

Validation

  • PHP syntax checks for all changed PHP files
  • PHP_CodeSniffer for all changed PHP files
  • JavaScript lint for all changed JavaScript files
  • Focused Jest: 6 tests passed
  • Full Jest: 53 suites and 954 tests passed
  • Focused PHPUnit: 27 tests and 56 assertions passed
  • Full PHPUnit: 876 tests and 1,872 assertions passed; 15 tests skipped by the existing suite
  • npm run build
  • git diff --check
  • Automated Edge check: one visible notice, one polite live-region update after load, and no focus movement into the notice or live region
  • Manual Edge and NVDA check: one spoken "Settings saved" confirmation after page load

Checklist

  • PR is linked to the main issue in the repo
  • Tests are added that cover changes

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The settings page now renders saved-status notices, conditionally loads wp-a11y, and announces success or failure messages through the admin JavaScript app. Jest and PHPUnit coverage validates announcement timing, politeness, notice rendering, and script dependencies.

Changes

Settings save status

Layer / File(s) Summary
Settings notice and script prerequisites
partials/settings-page.php, admin/class-enqueue-admin.php, tests/phpunit/partials/*, tests/phpunit/Admin/EnqueueAdminTest.php
The settings page renders queued notices, while the admin script conditionally depends on wp-a11y on the settings page.
Save-status announcement flow
src/admin/settings/announce-settings-save-status.js, src/admin/index.js, tests/jest/admin/announce-settings-save-status.test.js
The admin app announces settings results after page load, using polite speech for success notices and assertive speech for errors, with missing-state checks and timer-based tests.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SettingsPage
  participant AdminApp
  participant AnnounceSettingsSaveStatus
  participant WpA11y
  SettingsPage->>AdminApp: Render settings notice and initialize
  AdminApp->>AnnounceSettingsSaveStatus: Pass window.wp?.a11y
  AnnounceSettingsSaveStatus->>WpA11y: Speak notice message with politeness
Loading

Suggested reviewers: pattonwebz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR adds a status message announcement for settings saves and related accessibility behavior required by #1757.
Out of Scope Changes check ✅ Passed The changes stay focused on the settings-save announcement and its supporting tests, with no clear unrelated additions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: announcing settings save results to screen readers.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@benitoalba
benitoalba force-pushed the fix/1757-announce-settings-save-status branch from 29edf88 to 81c93ac Compare July 26, 2026 16:56
@benitoalba
benitoalba marked this pull request as ready for review July 26, 2026 17:07

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@tests/phpunit/partials/SettingsPagePartialTest.php`:
- Line 41: Update tests/phpunit/partials/SettingsPagePartialTest.php at lines
41-41 by renaming the test method to test_partial_renders_settings_saved_notice
and adding a : void return type. Update tests/phpunit/Admin/EnqueueAdminTest.php
at lines 106-106 by renaming the test method to
test_enqueue_base_script_with_wp_a11y_on_settings_page and adding a : void
return type, preserving each test’s existing behavior.
- Line 13: Move SettingsPagePartialTest into the
EqualizeDigital\AccessibilityChecker\Tests\Partials namespace and add the
corresponding PSR-4 mapping for tests/phpunit/ in composer.json or the PHPUnit
bootstrap/autoload configuration, ensuring the test remains discoverable and
runnable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 729ea44f-a921-401a-8e60-8bc88e122e04

📥 Commits

Reviewing files that changed from the base of the PR and between d733aa9 and 81c93ac.

📒 Files selected for processing (7)
  • admin/class-enqueue-admin.php
  • partials/settings-page.php
  • src/admin/index.js
  • src/admin/settings/announce-settings-save-status.js
  • tests/jest/admin/announce-settings-save-status.test.js
  • tests/phpunit/Admin/EnqueueAdminTest.php
  • tests/phpunit/partials/SettingsPagePartialTest.php

Comment thread tests/phpunit/partials/SettingsPagePartialTest.php
Comment thread tests/phpunit/partials/SettingsPagePartialTest.php
Comment thread admin/class-enqueue-admin.php Outdated
Comment on lines +86 to +91
$admin_script_dependencies = [ 'jquery' ];
if ( 'accessibility_checker_settings' === $page ) {
$admin_script_dependencies[] = 'wp-a11y';
}

wp_enqueue_script( 'edac', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/admin.bundle.js', $admin_script_dependencies, EDAC_VERSION, false );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's probably worth just putting this in the deps array everywhere rather than just conditionally on the one page.

Suggested change
$admin_script_dependencies = [ 'jquery' ];
if ( 'accessibility_checker_settings' === $page ) {
$admin_script_dependencies[] = 'wp-a11y';
}
wp_enqueue_script( 'edac', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/admin.bundle.js', $admin_script_dependencies, EDAC_VERSION, false );
wp_enqueue_script( 'edac', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/admin.bundle.js', [ 'jquery', 'wp-a11y' ], EDAC_VERSION, false );

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.

Updated as suggested: edac now includes wp-a11y on every admin page, and the non-settings regression test was updated. PHPUnit passes with 27 tests and 56 assertions, along with PHPCS.

@benitoalba
benitoalba requested a review from pattonwebz August 3, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changes Are Not Confirmed with a Status Message

2 participants