Skip to content

Fix[Meta Description]: Improve Copy and Focus Behavior#696

Open
yogeshbhutkar wants to merge 4 commits into
WordPress:developfrom
yogeshbhutkar:feat/meta-description-a11y
Open

Fix[Meta Description]: Improve Copy and Focus Behavior#696
yogeshbhutkar wants to merge 4 commits into
WordPress:developfrom
yogeshbhutkar:feat/meta-description-a11y

Conversation

@yogeshbhutkar

@yogeshbhutkar yogeshbhutkar commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What, Why, and How?

Related to #589

This PR addresses the following issues:

  1. Disables the Accept button in the Meta Description modal while generation is in progress to prevent users from accidentally closing the modal and losing the ongoing generation state.
  2. Fixes focus loss after accepting the first generated description. Since the modal initiator, the Generate button, disappears after the first generation, focus is moved to the Edit description button. Subsequent focus handling is managed by the modal as expected.
  3. Visually separates the Cancel button and moves it to the right to emphasize that it can be a destructive action, as closing the modal discards the ongoing generation state.
  4. Disables the text area while generation is in progress, since any edits made during generation would be overwritten by the generated content once it completes.
  5. Fixes the disabled Copy button remaining clickable when useCopyToClipboard is used with accessibleWhenDisabled, by only applying the hook’s returned ref when the button is enabled.
  6. Updates the copy feedback when the description changes. Previously, the Copied message remained visible for a fixed 4000ms even after the text was edited. It now immediately resets to Copy to clipboard, giving users accurate feedback.

Use of AI Tools

AI assistance: Yes
Tool(s): Codex
Model(s): GPT-5.5
Used for: Initial code skeleton; final implementation was reviewed and edited by me.

Testing Instructions

  1. Open the Meta Description experiment in the editor.
  2. Generate a meta description.
  3. Verify the modal opens with generated text.
  4. Verify focus is handled correctly.
  5. Close the modal.
  6. Verify focus is not lost.
  7. Verify disabled copy does nothing.
  8. Edit or regenerate the description.
  9. Verify copy, apply, and cancel states.

Screencast

screencast.mov

Changelog Entry

Fixed - Prevent accidental interactions and stale feedback in the Meta Description generation modal and improve focus handling.

Open WordPress Playground Preview

@yogeshbhutkar yogeshbhutkar marked this pull request as ready for review June 10, 2026 12:27
@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: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>

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

setShowCopyConfirmation( true );
if ( timeoutIdRef.current ) {
clearTimeout( timeoutIdRef.current );
const pendingCopyTextRef = useRef< string | null >( null );

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this new ref needed? I may be wrong but looking at the code it seems like things would work the same without this

@dkotter dkotter added this to the 1.1.0 milestone Jun 10, 2026
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.

2 participants