Skip to content

Conversation

@maxschmeling
Copy link

What?

Fixes #71698

Preserve active formatting during programmatic annotation changes.

Why?

See the original report in #71698.

When typing with active formatting, programmatic changes to the annotations would cause active formats to be lost.

How?

Filters out annotation formats (editor-only) from activeFormats in getActiveFormats and related code paths, and preserves user activeFormats (e.g., bold) when annotations are applied programmatically, so annotations don't interfere with typing.

Testing Instructions

Instructions copied from the original issue:

  1. Using word-example.js from the gist
  2. enable bold formatting in a paragraph
  3. start typing words
  4. Type the word apple
  5. continue typing
  6. see that bold has been disabled after the word apple

  1. Using shortcut-example.js
  2. Create a paragraph with some text
  3. hit mod+shift+L
  4. The whole paragraph should be annotated now in the centre of the annotation
  5. Enable bold by clicking the tool bar
  6. type two letters
  7. the first will be bold the second will not

Testing Instructions for Keyboard

This change is entirely about typing in editable areas.

Screenshots or screencast

before.mp4
after.mp4

@github-actions
Copy link

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: maxschmeling <[email protected]>
Co-authored-by: jrmd <[email protected]>

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

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Nov 18, 2025
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @maxschmeling! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@maxschmeling maxschmeling force-pushed the fix/71698/active-format-preservation branch from 7f1a60a to 3b5b029 Compare November 18, 2025 16:38
@ingeniumed ingeniumed added [Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration [Type] Experimental Experimental feature or API. and removed [Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration [Type] Experimental Experimental feature or API. labels Nov 18, 2025
@maxschmeling maxschmeling force-pushed the fix/71698/active-format-preservation branch 2 times, most recently from 6b8c209 to 9bd8296 Compare November 20, 2025 18:35
@maxschmeling maxschmeling force-pushed the fix/71698/active-format-preservation branch from 6e9cd78 to 0ece9a2 Compare November 24, 2025 23:04
@chriszarate chriszarate added [Type] Bug An existing feature does not function as intended [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable labels Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Applying a format/annotation programattically messes with the active format

3 participants