Repository navigation
Rich Text: Mark undo levels from the change handler - #86007
Conversation
Each rich text field ran useMarkPersistent on every render: a debounced function, a layout effect comparing snapshots, and five other hooks. Only the selected field changes, so decide the undo level when it does: a change starts a new level when the field's last change was a format change or more than a second ago. Cross-block formatting marks its own change, since no field sees it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🤖 PR meta 🤖🎉 PropsIf 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: -124 B (0%) Total Size: 8.56 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Undo restores the post selection when another synced entity is loaded (RTC WebSocket) in
|
Rich Text: Mark undo levels from the change handler (WordPress#86007)
|
There was a conflict while trying to cherry-pick the commit to the wp/7.2 branch. Please resolve the conflict manually and create a PR to the wp/7.2 branch. PRs to wp/7.2 are similar to PRs to trunk, but you should base your PR on the wp/7.2 branch instead of trunk. |
|
Backported: #87426 87386 |
This updates the pinned commit hash of the Gutenberg repository from `c5bdc7f4898ec98114cdccbe1cacec7a979b85cc` to `423bdf39aaa34a710acc338d3e89eac5b920fe6d` (head of the `wp/7.2` branch). A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@c5bdc7f...423bdf3. - Rich Text: Mark undo levels from the change handler (WordPress/gutenberg#86007) (WordPress/gutenberg#87386) - Editor: Make plugin icons in the Options menu follow the text color (WordPress/gutenberg#87399) (WordPress/gutenberg#87405) - Entity Fields: Track wp_entity_fields_api_init firing internally in the registry (WordPress/gutenberg#87387) (WordPress/gutenberg#87450) - Block Editor: Count every rendered inspector group when showing the Styles tab (WordPress/gutenberg#87403) (WordPress/gutenberg#87475) - iOS: Put the caret back when iOS clears it after a tap (WordPress/gutenberg#87569) - Abilities: Accept non-ASCII URLs in the `uri` schema format (WordPress/gutenberg#86844) - Writing flow: Keep shift+arrow selection inside a block edited as HTML (WordPress/gutenberg#84135) Developed in: #16361 Props isabel_brison, ramonopoly. See #66340. git-svn-id: https://develop.svn.wordpress.org/trunk@65840 602fd350-edb4-49c9-b593-d223f7449a82
This updates the pinned commit hash of the Gutenberg repository from `c5bdc7f4898ec98114cdccbe1cacec7a979b85cc` to `423bdf39aaa34a710acc338d3e89eac5b920fe6d` (head of the `wp/7.2` branch). A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@c5bdc7f...423bdf3. - Rich Text: Mark undo levels from the change handler (WordPress/gutenberg#86007) (WordPress/gutenberg#87386) - Editor: Make plugin icons in the Options menu follow the text color (WordPress/gutenberg#87399) (WordPress/gutenberg#87405) - Entity Fields: Track wp_entity_fields_api_init firing internally in the registry (WordPress/gutenberg#87387) (WordPress/gutenberg#87450) - Block Editor: Count every rendered inspector group when showing the Styles tab (WordPress/gutenberg#87403) (WordPress/gutenberg#87475) - iOS: Put the caret back when iOS clears it after a tap (WordPress/gutenberg#87569) - Abilities: Accept non-ASCII URLs in the `uri` schema format (WordPress/gutenberg#86844) - Writing flow: Keep shift+arrow selection inside a block edited as HTML (WordPress/gutenberg#84135) Developed in: WordPress/wordpress-develop#16361 Props isabel_brison, ramonopoly. See #66340. Built from https://develop.svn.wordpress.org/trunk@65840 git-svn-id: http://core.svn.wordpress.org/trunk@64869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This updates the pinned commit hash of the Gutenberg repository from `c5bdc7f4898ec98114cdccbe1cacec7a979b85cc` to `423bdf39aaa34a710acc338d3e89eac5b920fe6d` (head of the `wp/7.2` branch). A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@c5bdc7f...423bdf3. - Rich Text: Mark undo levels from the change handler (WordPress/gutenberg#86007) (WordPress/gutenberg#87386) - Editor: Make plugin icons in the Options menu follow the text color (WordPress/gutenberg#87399) (WordPress/gutenberg#87405) - Entity Fields: Track wp_entity_fields_api_init firing internally in the registry (WordPress/gutenberg#87387) (WordPress/gutenberg#87450) - Block Editor: Count every rendered inspector group when showing the Styles tab (WordPress/gutenberg#87403) (WordPress/gutenberg#87475) - iOS: Put the caret back when iOS clears it after a tap (WordPress/gutenberg#87569) - Abilities: Accept non-ASCII URLs in the `uri` schema format (WordPress/gutenberg#86844) - Writing flow: Keep shift+arrow selection inside a block edited as HTML (WordPress/gutenberg#84135) Developed in: #16361 Reviewed by Mamaduka. Merges r65840 to the 7.2 branch. Props peterwilsoncc, isabel_brison, ramonopoly. See #66340. git-svn-id: https://develop.svn.wordpress.org/branches/7.2@65843 602fd350-edb4-49c9-b593-d223f7449a82
This updates the pinned commit hash of the Gutenberg repository from `c5bdc7f4898ec98114cdccbe1cacec7a979b85cc` to `423bdf39aaa34a710acc338d3e89eac5b920fe6d` (head of the `wp/7.2` branch). A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@c5bdc7f...423bdf3. - Rich Text: Mark undo levels from the change handler (WordPress/gutenberg#86007) (WordPress/gutenberg#87386) - Editor: Make plugin icons in the Options menu follow the text color (WordPress/gutenberg#87399) (WordPress/gutenberg#87405) - Entity Fields: Track wp_entity_fields_api_init firing internally in the registry (WordPress/gutenberg#87387) (WordPress/gutenberg#87450) - Block Editor: Count every rendered inspector group when showing the Styles tab (WordPress/gutenberg#87403) (WordPress/gutenberg#87475) - iOS: Put the caret back when iOS clears it after a tap (WordPress/gutenberg#87569) - Abilities: Accept non-ASCII URLs in the `uri` schema format (WordPress/gutenberg#86844) - Writing flow: Keep shift+arrow selection inside a block edited as HTML (WordPress/gutenberg#84135) Developed in: #16361 Reviewed by Mamaduka. Merges r65840 to the 7.2 branch. Props peterwilsoncc, isabel_brison, ramonopoly. See #66340. Built from https://develop.svn.wordpress.org/branches/7.2@65843 git-svn-id: http://core.svn.wordpress.org/branches/7.2@64872 1a063a9b-81f0-0310-95a4-ce76da25c4cd
What?
Follow up to #57435 and #83463.
Rich text fields decide undo levels when they change, instead of after every render. An unselected paragraph's rich text drops 6 hooks (74 to 68), including a layout effect that ran after every render.
Why?
Every rich text field paid for undo grouping on mount and on every render, but only the field being edited changes. Watching renders also let changes from outside the field end the current undo level, such as leaving bold with the arrow key while typing.
How?
useRichTextcallsonChangeinsideregistry.batch, so the change would get its own level, and Cmd+B with no selection would leave an undo level that changes nothing.useMarkPersistent, its unit test and types.Changed behaviour: leaving a format with the arrow key between typing no longer ends the undo level, the same as any other arrow key. The new e2e test for this fails on trunk.
Time per block (CPU, 500 paragraphs, 8 paired rounds): trunk about 78.2 µs, this PR about 78.6 µs, with ±2 µs noise on a loaded machine. Not measurable.
Testing Instructions
Open in Playground: a post with a paragraph that ends in bold text and a plain one, open in the editor.
Testing Instructions for Keyboard
All steps above use the keyboard only.
Screenshots or screencast
No visual change: this changes which edits undo together. The e2e tests in
undo.spec.jscover it.Use of AI Tools
Written with Claude Code (Claude Opus 5.5), directed by @ellatrix.
🤖 Generated with Claude Code