-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix converting a reusable block with nested blocks into a static block #11188
Conversation
The CONVERT_BLOCK_TO_STATIC effect needs to handle the case where the block being converted has inner blocks.
newBlocks = [ createBlock( | ||
referencedBlock.name, | ||
referencedBlock.attributes, | ||
referencedBlock.innerBlocks |
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.
I think we should clone the blocks before calling this:
- Insert the reusable block twice
- Convert one of them to regular
- Edit the regular blocks (notice they change in both blocks)
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.
Good catch! Fixed in a7464db.
By using cloneBlock(), we correctly make a copy of the innerBlocks which means that updates to one block don't affect another.
Can you please reconsider and include this in 4.2? I know I’m been nagging about this issue and I promise this is the last time, whatever you decide 😁 |
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.
LGTM 👍
@noisysocks - sorry - was a bit slow to review this. The only thing I spotted is that I can now nest a reusable block inside of itself, which causes an infinite recursion and my chrome tab ran out of memory! I know, I know, but I had to try it! 🤣 Want me to create an issue about that? |
@talldan I don't think it's related to this PR but I saw an issue about it (created yesterday I think) |
Thanks, found it - #11206 |
Fixes #9278.
The
CONVERT_BLOCK_TO_STATIC
effect needs to handle the case where the block being converted has inner blocks.Testing