Skip to content

Real-time collaboration: Don't sync core/freeform block without content - #73983

Closed
chriszarate wants to merge 1 commit into
trunkfrom
fix/sync-freeform-block-without-content
Closed

chriszarate wants to merge 1 commit into
trunkfrom
fix/sync-freeform-block-without-content

Conversation

@chriszarate

Copy link
Copy Markdown
Contributor

What?

Don't sync core/freeform (Classic) block without a defined content attribute.

Why?

A core/freeform block without a defined content attribute triggers an open modal. If we sync the block in this "not-ready" state, connected peers will experience an open modal as well.

How?

Withhold syncing until the content attribute is defined. This follows a similar approach used to withhold syncing of gallery blocks until the uploaded images are available.

Testing Instructions

  1. Check out branch.
  2. Add a "Classic" block.
  3. Ensure modal only opens for the user who added the block.

Testing Instructions for Keyboard

n/a

Screenshots or screencast

Before

classic-before.mov

After

classic-after.mov

@chriszarate
chriszarate requested a review from nerrad as a code owner December 12, 2025 23:01
@chriszarate chriszarate added [Type] Bug An existing feature does not function as intended [Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration labels Dec 12, 2025
@youknowriad

Copy link
Copy Markdown
Contributor

cc @ellatrix This one is interesting :)

I think this indicates that some attributes should be "local state". In fact, we already have some attributes that are considered "local" state. The attributes with "role": "local", are we ignoring these attributes already when syncing?

This makes me wonder if there's a different way to handle this issue. Maybe the "freeform" should be synced but the modal being open or not, shouldn't be triggered by the "content" being empty or not, but instead by a new separate block attribute that is marked "local". WDYT @ellatrix ?

@github-actions

github-actions Bot commented Dec 15, 2025 •

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: chriszarate <czarate@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: azaozz <azaozz@git.wordpress.org>

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

// that other peers can render them correctly.
return ! block.innerBlocks.some(
( innerBlock ) =>
innerBlock.attributes && innerBlock.attributes.blob

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not great that we're hardcoding "blob" here, it seems this related to my "local" attribute suggestion.

@ellatrix

Copy link
Copy Markdown
Member

Yes, perhaps there's some other way to open the modal. The modal should actually only open when the user first inserts the block, afterwards it shouldn't open by itself. It seems it's impossible to save an empty freeform block, so the only way this would pop up is by inserting a freeform block programmatically.

The interesting thing is that when a freeform block is empty, it's not serialized at all (there's no block delimiters), so if the syncing was based on the serialized content, there would be no freeform block in the second instance. So in a way the whole block is "local".

@chriszarate

Copy link
Copy Markdown
Contributor Author

The attributes with "role": "local", are we ignoring these attributes already when syncing?

@youknowriad We're not. That's a viable alternate approach for image/video blocks, because they have a placeholder state that peers will see while the originating user selects and uploads their media. Here's what that would look like:

image-local-attribute.mov

However, the core/freeform block has no such placeholder state and, as @ellatrix notes, the block does not truly exist (in serialized form) without a populated content attribute. Therefore, withholding the entire block from syncing makes a kind of sense.

We should probably move towards a consistent approach for core blocks—an approach that can be easily understood and adopted by custom block developers.

From a syncing perspective, which approach is ideal?

  1. Blocks should always have a visible and actionable state, even when they are incomplete or invalid. The simplest form is a Placeholder component. This communicates the originating user's intent (and possibly their progress) as they configure the block.
    • The potential downside is that syncing placeholder state or partially configured blocks might confuse observing peers. They might think the block is broken. Presence indicators could work to lessen this confusion by communicating progress in more detail.
  2. Blocks should have the ability to communicate when they are "ready" to be synced. Until such time, like the core/freeform block, the entire block is "local."
    • What might be a config-driven way to implement this?
  3. Support both approaches?

@youknowriad

Copy link
Copy Markdown
Contributor

I think for me, blocks should not have to tell when they are ready to sync or not, they should always sync. Some local state though make sense, for instance the "blob" attribute we don't want gallery and image blocks to upload images in two places. The modal can fall in this category.

@ellatrix

ellatrix commented Jan 7, 2026

Copy link
Copy Markdown
Member

I think we tried a PR at some point to always serialize new freeform blocks (except if the whole content is freeform). But I can't find it now. Cc @tyxla @azaozz

@azaozz

azaozz commented Jan 11, 2026 •

Copy link
Copy Markdown
Contributor

It seems it's impossible to save an empty freeform block, so the only way this would pop up is by inserting a freeform block programmatically.

The interesting thing is that when a freeform block is empty, it's not serialized at all (there's no block delimiters)

Right, the freeform block is actually not a block at all. It is some loose stuff (or HTML) left over outside of block delimiters. The freeform block is a hack to present that loose HTML as a block that was used to trigger a TinyMCE instance. This "hack" was somewhat useful 6-7 years ago (at the beginning of Gutenberg) for backwards compatibility. However that usefulness has disappeared in recent years (even TinyMCE instances are not triggered the same way any more).

I think we tried a PR at some point to always serialize new freeform blocks (except if the whole content is freeform).

Yea, there were some attempts few years ago to turn the (fake) freeform block into an actual block (with delimiters) that can be saved/serialized. Think that was dropped in favour of replacing the freeform blocks with HTML blocks (as that's what they actually are). At the time this didn't seem to get enough support, but maybe now it will? I'm still convinced that streamlining/fixing how Gutenberg handles loose HTML will be a very worthy improvement.

@chriszarate

Copy link
Copy Markdown
Contributor Author

I've opened a follow-up to address Riad's narrow suggestion around attributes with role=local. The original issue with core/freeform was resolved by #74162, which moved the modal decision to local state.

@chriszarate chriszarate closed this Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants