Skip to content

Repair wp/5.1 branch Actions: Wait for the caret before bolding in the writing flow test - #830

Closed
desrosj wants to merge 1 commit into
fix-actions-5.1/update-undo-snapshot-spacefrom
fix-actions-5.1/wait-for-caret-in-writing-flow-test
Closed

desrosj wants to merge 1 commit into
fix-actions-5.1/update-undo-snapshot-spacefrom
fix-actions-5.1/wait-for-caret-in-writing-flow-test

Conversation

@desrosj

@desrosj desrosj commented Oct 21, 2026

Copy link
Copy Markdown
Owner

What?

Makes adding blocks › should clean TinyMCE content in test/e2e/specs/writing-flow.test.js wait for the new block's caret before pressing the bold shortcut.

Why?

The test fails intermittently on wp/5.1, receiving <p>Inside</p> instead of <p><strong>Inside</strong></p>. Backspace replaces the empty paragraph with a new default block, and that block's RichText learns where the caret is only from the next selectionchange event. An event trace of failing runs showed the bold shortcut arriving first in every failure: RichText was selected and handled the shortcut, but its selection start and end were still undefined, so no format placeholder was rendered.

How?

Before Backspace, the test registers a selectionchange listener that sets a flag once the selection is inside a newly focused contenteditable. After Backspace, it waits for that flag before pressing the shortcut. Upstream never fixed this test; it was deleted in WordPress@0f01eec (WordPress#13697) when RichText stopped relying on the DOM for format boundaries.

Testing Instructions

A throwaway diagnostic ran links.test.js and writing-flow.test.js together 30 times per variant (run 39531134819). The test failed in 10 of 30 runs with the unchanged spec and 0 of 30 with this change. ESLint passes on the file.

Use of AI Tools

This PR was created by Claude Code under my supervision. All code should be treated as AI-produced and not yet reviewed by a human until this PR is marked Ready for Review.

🤖 Generated with Claude Code

https://claude.ai/code/session_013wZdkg9DSpSbQmRpBymFfV

@desrosj
desrosj added this pull request to stack #831 October 21, 2026 02:39
@desrosj
desrosj marked this pull request as ready for review October 26, 2026 18:54
@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: desrosj <desrosj@git.wordpress.org>

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

Backspace in the empty paragraph replaces it with a new default block.
That block's RichText learns where the caret is only from the next
`selectionchange` event. When the bold shortcut arrived first, RichText
had no caret position, so no format placeholder was rendered and
"Inside" was typed without bold.

Wait for a `selectionchange` in the newly focused block before pressing
the shortcut.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wZdkg9DSpSbQmRpBymFfV
@desrosj

desrosj commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Moved to WordPress#85677.

@desrosj desrosj closed this Oct 26, 2026
@desrosj
desrosj deleted the fix-actions-5.1/wait-for-caret-in-writing-flow-test branch October 29, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant