Skip to content

Improve a11y of Meta Description modal controls#445

Merged
dkotter merged 3 commits intoWordPress:developfrom
t-hamano:a11y/meta-description
Apr 21, 2026
Merged

Improve a11y of Meta Description modal controls#445
dkotter merged 3 commits intoWordPress:developfrom
t-hamano:a11y/meta-description

Conversation

@t-hamano
Copy link
Copy Markdown
Contributor

@t-hamano t-hamano commented Apr 17, 2026

Part of #180

What?

This PR fixes some issues related to a11y in the meta description modal.

Why? How?

The key points of the problem and solution are as follows:

  • Depending on the specific state, the disabled attribute is added to the button. Buttons with the disabled attribute are not focusable, leading to a loss of focus. To resolve this, the accessibleWhenDisabled prop is available.
  • When the description is copied, a snackbar appears, but it does not notify the screen reader. In the first place, the snackbar itself is not appropriate because the modal background is expected to be non-interactive. This PR the button text when copied and notifies the screen reader via the speak() method that the copy action has been performed.

Here are some additional changes I'd like to propose, but they are outside the scope of this PR.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 4.7
Used for: Refactoring the copy button to match Gutenberg's CopyButton pattern and wiring up accessibleWhenDisabled. All output was reviewed by me.

Testing Instructions

Generate Meta Description

  1. Open the Meta Description Modal.
  2. Wait for the automatic generation of the meta description to complete.
  3. Click the Generate button.
    • Before: The focus is lost.
    • After: The focus remains on the Generate button.
generate-buton.mp4

Close Meta Description Modal

  1. Open the Meta Description Modal.
  2. Close the modal before the description generation is complete.
    • Before: The focus is lost.
    • After: Focus returns to the button that triggered the modal.

Incidentally, since the "Generate Meta Description" button is a button to trigger a modal, the isBusy and disabled props should not be necessary in the first place. Ideally, the description generation should be canceled when the modal is closed, but this is out of scope for this PR.

close-modal.mp4

Copy Meta Description

  1. Open the Meta Description Modal.
  2. Wait for the automatic generation of the meta description to complete.
  3. Click the "Copy to clipboard" button.
    • Nothing is announced by the screen reader.
    • The screen reader announces Meta description copied to clipboard..
copy.mp4

Changelog Entry

Changed - Improve accessibility of the Meta Description modal: inline "Copied!" confirmation on the copy button and accessibleWhenDisabled on disabled controls.

Open WordPress Playground Preview

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.41%. Comparing base (e63d8c0) to head (37b5e87).
⚠️ Report is 21 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #445   +/-   ##
==========================================
  Coverage      67.41%   67.41%           
  Complexity       907      907           
==========================================
  Files             59       59           
  Lines           4352     4352           
==========================================
  Hits            2934     2934           
  Misses          1418     1418           
Flag Coverage Δ
unit 67.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

t-hamano and others added 3 commits April 21, 2026 18:45
- Show inline "Copied!" confirmation on the copy button instead of a
  snackbar notice so feedback is announced next to the triggering action.
- Add accessibleWhenDisabled to disabled buttons so they remain focusable
  and discoverable by screen readers.
- Drop disabled/isBusy from the initial Generate button so it stays
  actionable while the modal handles the loading state.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The inline "Copied!" label change is silent for keyboard/screen-reader
users because the button retains focus and screen readers do not
re-announce a changed child text. Use speak() from @wordpress/a11y to
deliver the confirmation through the shared live region.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Disable the Generate Meta Description button and mark it busy while a
request is in flight so assistive tech users get the same state
feedback as the Regenerate control, and to prevent duplicate requests.
@t-hamano t-hamano force-pushed the a11y/meta-description branch from e7ae595 to 37b5e87 Compare April 21, 2026 09:54
@t-hamano t-hamano marked this pull request as ready for review April 21, 2026 10:13
@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

onClose: () => void;
}

function CopyButton( {
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.

This implementation is almost identical to this one.

@jeffpaul jeffpaul added this to the 0.8.0 milestone Apr 21, 2026
@jeffpaul jeffpaul requested a review from dkotter April 21, 2026 15:46
@dkotter dkotter merged commit 43d3bde into WordPress:develop Apr 21, 2026
34 of 35 checks passed
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.

3 participants