Repository navigation
Real-time collaboration: Don't sync core/freeform block without content - #73983
chriszarate wants to merge 1 commit into
Conversation
|
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 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 ? |
|
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 If 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. |
| // that other peers can render them correctly. | ||
| return ! block.innerBlocks.some( | ||
| ( innerBlock ) => | ||
| innerBlock.attributes && innerBlock.attributes.blob |
There was a problem hiding this comment.
It's not great that we're hardcoding "blob" here, it seems this related to my "local" attribute suggestion.
|
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". |
@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.movHowever, the 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?
|
|
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. |
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).
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. |
|
I've opened a follow-up to address Riad's narrow suggestion around attributes with |
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
Testing Instructions for Keyboard
n/a
Screenshots or screencast
Before
classic-before.mov
After
classic-after.mov