-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Hitting enter in text block updates the block's client id. #26252
Comments
This is also reproducible in the post editor. This seems to be caused by how RichText's onSplit prop works: The callback will be triggered twice once for the first part of the text, and again for the second part. The original block is then replaced with the two new blocks: So I guess the proposal would be to preserve the first block's clientId, but it seems like a pretty big API change at this stage. cc @ellatrix. |
Just to add as well, this wouldn't be just an issue with the paragraph block, but also any block that implements gutenberg/packages/block-editor/src/components/rich-text/index.js Lines 302 to 312 in 9595803
Probably merging the block created as a result of calling |
Is there a way to listen for a split? Maybe in just |
What's the use case for this? Can't it be seen as removing a block and replacing it with two new ones? |
The menus and widget screens rely on a stable mapping from persisted entities to block ids. If that persistence breaks, the old widget/menu-item is deleted and recreated. This can cause a couple of issues.
|
I think we can now close it as the widget screen doesn't rely on The original issue with the widget screen is not fixed yet though. I opened #30268 to better track it. I think we can close this as duplicated. |
Describe the bug
If my selection is in a text block, hitting the enter button to create a new paragraph updates the
clientId
of the original text block.To reproduce
data-block
attribute. Record it's value.data-block
attribute of your first block. Notice it is now different.Expected behavior
The client id should stay the same.
Editor version (please complete the following information):
master
.Desktop (please complete the following information):
Additional context
This completely breaks the Widgets screen as it relies on a stable
clientId
to map widget IDs to block. Otherwise, duplicate blocks end up being created.https://i.imgur.com/1TJXvG7.gifv
The text was updated successfully, but these errors were encountered: