Content Resizing: Focus Accept button when suggested content generation completes - #917
Conversation
… ContentResizingToolbar
…date package-lock.json
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dkotter
left a comment
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 ] ); |
There was a problem hiding this comment.
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
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