-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Block Editor: Avoid wiping out inner block controller content when ungrouping #37274
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
Conversation
|
Size Change: +56 B (0%) Total Size: 1.11 MB
ℹ️ View Unchanged
|
|
|
||
| // The blocks in block selection don't include inner blocks for the inner block controller. | ||
| // We've to add them manually to avoid data loss. | ||
| const newBlocks = innerBlocks.map( ( block ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be recursive? Also have you tried converting a TP to Group -> Ungroup -> Group again? In my testing fails.
I think this is something that needs to be handled elsewhere and probably in use-block-sync, but I haven't pinpointed yet the proper change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this should be recursive if we go with a similar solution.
As I mentioned, this solution doesn't work quite well. I decided to share anyway as a starting point and for detail.
I think this is something that needs to be handled elsewhere and probably in use-block-sync, but I haven't pinpointed yet the proper change.
Same 😅
|
I'd like to take some time to see if I can figure out the root issue, I'll keep you updated. |
|
I am closing this in favor of #37280. |
Description
See #36788.
When grouping and ungrouping inner block controller blocks (Template Parts, Reusable Blocks), their content is wiped out.
Why
getBlocksByClientIdfor block(s) data, which calls thegetBlockinternally.getBlockwon't return inner blocks when another entity controls them, aka "Controlled Inner Blocks."innerBlocks.I thought I could manually set inner blocks for controlled entities (see current code), but this method only works halfway. The controlled inner blocks still get deleted after saving the post.
My best guess is that this has something to do with how the
useBlockSyncworks.@noahtallen, @youknowriad I would appreciate any feedback you can provide for this issue 🙇
How has this been tested?
Types of changes
Bugfix
Checklist:
*.native.jsfiles for terms that need renaming or removal).