Skip to content

Content Resizing: Focus Accept button when suggested content generation completes - #917

Open
Infinite-Null wants to merge 2 commits into
WordPress:developfrom
Infinite-Null:feat/content-resizing-focus-accept-button
Open

Content Resizing: Focus Accept button when suggested content generation completes#917
Infinite-Null wants to merge 2 commits into
WordPress:developfrom
Infinite-Null:feat/content-resizing-focus-accept-button

Conversation

@Infinite-Null

@Infinite-Null Infinite-Null commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What?

Ensures focus moves directly to the Accept button in the Content Resizing modal once suggested content generation finishes, rather than defaulting focus to any focusable elements (such as links) rendered in the "Original" content section.

Why?

If the original block text contains focusable HTML elements (e.g., hyperlinks), modal updates cause focus to land on those elements in the "Original" section.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 4.6
Used for: Validating bug, suggesting a fix.

Testing Instructions

Below is the video demonstrating the testing instructions.

Screen.Recording.2026-08-06.at.5.37.12.PM.mov

Screenshots or screencast

Before:

Screen.Recording.2026-08-06.at.5.40.05.PM.mov

After

Screen.Recording.2026-08-06.at.5.40.42.PM.mov

Changelog Entry

Fixed - Ensure focus moves to the Accept button when suggested content generation completes in the Content Resizing modal.

Open WordPress Playground Preview

@Infinite-Null
Infinite-Null requested a review from a team August 6, 2026 12:14
@github-actions

github-actions Bot commented Aug 6, 2026

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: Infinite-Null <ankitkumarshah@git.wordpress.org>

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

@Infinite-Null Infinite-Null changed the title Feat/content resizing focus accept button Content Resizing: Focus Accept button when suggested content generation completes Aug 6, 2026
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.43%. Comparing base (5599e9d) to head (0fc0ee8).

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #917   +/-   ##
==========================================
  Coverage      80.43%   80.43%           
  Complexity      2565     2565           
==========================================
  Files            110      110           
  Lines          10448    10448           
==========================================
  Hits            8404     8404           
  Misses          2044     2044           
Flag Coverage Δ
unit 80.43% <ø> (ø)

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

☔ View full report in Codecov by Harness.
📢 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.

@dkotter dkotter added this to the 1.3.0 milestone Aug 6, 2026
@jeffpaul jeffpaul moved this from Triage to Needs review in WordPress AI Roadmap Aug 10, 2026

@jeffpaul jeffpaul left a comment

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.

Tests well via Playground, will await @dkotter's review before merging

@jeffpaul
jeffpaul requested a review from dkotter August 10, 2026 17:44
@jeffpaul jeffpaul mentioned this pull request Aug 10, 2026
45 tasks

@dkotter dkotter 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.

Works fine but left a few minor comments.

Also would be nice to update our existing E2E test to ensure the right button is focused after generation, to ensure this issue doesn't come back (and likely something we've missed in our other E2E tests and focus fixes)

}, [ isModalOpen, suggestedContent ] );

if ( ! isLoading && suggestedContent !== null ) {
acceptButtonRef.current?.focus();

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.

Correct me if I'm wrong but I believe doing focus() will automatically scroll an element into view, which we already do the line above: acceptButtonRef.current?.scrollIntoView. Likely not a problem but should maybe do:

acceptButtonRef.current?.focus( { preventScroll: true } );

to prevent conflicts between the two?

if ( ! isLoading && suggestedContent !== null ) {
acceptButtonRef.current?.focus();
}
}, [ isModalOpen, isLoading, suggestedContent ] );

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.

By adding isLoading here, we re-trigger the scroll on every loading transition, which is new behavior. Might be better to introduce a new effect for the focus state to avoid this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs review

Development

Successfully merging this pull request may close these issues.

3 participants