Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collab: Active RichText formats can reset unexpectedly #58

Open
mirka opened this issue Sep 14, 2021 · 1 comment
Open

Collab: Active RichText formats can reset unexpectedly #58

mirka opened this issue Sep 14, 2021 · 1 comment
Labels
bug Something isn't working [Feature] Collaboration Real-time collaborative editing

Comments

@mirka
Copy link
Member

mirka commented Sep 14, 2021

Active RichText formats (like bold, italics, inline code) can be deactivated when a peer edit comes in, or if there is a peer caret in the same block.

Steps to reproduce

  1. In one client, hit the Bold button and start typing in bold.
  2. On the other client, type something in a different block.
  3. Go back to the other client, and it's not in Bold mode anymore.
CleanShot.2021-09-15.at.01.04.47.mp4
@mirka mirka added bug Something isn't working [Feature] Collaboration Real-time collaborative editing labels Sep 14, 2021
@mirka mirka changed the title Collab: RichText formats can reset when a peer edit is received Collab: Active RichText formats can reset unexpectedly Jan 27, 2022
@mirka
Copy link
Member Author

mirka commented Jan 28, 2022

The problem occurs when this returns a new object while the self caret is within an active format.

// The properties in this return object need to be as stable as possible.
// See https://github.com/WordPress/gutenberg/issues/23428
return {
carets: getCarets( select( 'isolated/editor' ).getCollabPeers(), richTextIdentifier, blockClientId ),
multilineTag,
blockAttributeSelector: getStableBlockAttributeSelector(
select( 'core/block-editor' ).getBlockAttributes,
blockClientId,
richTextIdentifier
),
};

It might be something that should be addressed upstream (WordPress/gutenberg#23428). I haven't yet found a way to work around it. I thought maybe we could remember the select('core/block-editor').isCaretWithinFormattedText() value and restore it with dispatch('core/block-editor').enterFormattedText(), but that wasn't sufficient.

https://github.com/WordPress/gutenberg/blob/trunk/packages/block-editor/src/components/rich-text/use-caret-in-format.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working [Feature] Collaboration Real-time collaborative editing
Projects
None yet
Development

No branches or pull requests

1 participant