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
InnerBlocks Template Adjustments Cause Content Loss #8109
Comments
I think I'm experiencing the same issue as the above.
If I add a list or button block in the editor and save, those blocks are no longer visible upon refresh. |
I'm also having the same issue as described above. When I try to set a template, any additional content that is added to the block disappears on refresh. The newly added content is visible on the front end, but does not display in the editor. Here is a video showing the bug.
Another quirk with the template, I can change the text within those placeholder blocks and it will update as expected, but if I try to delete a placeholder block entirely, it will regenerate after save and refresh. |
I'm able to reproduce this problem in a simple test block. |
I ran into a similar issue and accidentally opened a duplicate of this issue with #9349. I'll paste my sample code into here for easy replication of the issue: const { Fragment } = wp.element;
const {
InnerBlocks,
} = wp.editor;
const { __ } = wp.i18n;
const ALLOWED_BLOCKS = [ 'core/image' ];
const TEMPLATE = [
[ 'core/image' ],
[ 'core/image' ],
[ 'core/image' ],
];
export const name = 'myplugin/test';
export const settings = {
title: __( 'Test', 'textdomain' ),
category: 'layout',
icon: 'grid-view',
attributes: {},
edit: () => {
return (
<Fragment>
<div className="my-blocks-container">
<InnerBlocks
allowedBlocks={ ALLOWED_BLOCKS }
template={ TEMPLATE }
templateLock={ false }
/>
</div>
</Fragment>
);
},
save: () => {
return (
<div className="my-blocks-container">
<InnerBlocks.Content />
</div>
);
},
}; The issue is a result of the |
@jorgefilipecosta Thanks for getting this one solved! So excited to see it closed. |
Describe the bug
I've been playing around with the InnerBlocks template options found here InnerBlocks. I've noticed when removing an existing block or adding a new block that the template will remove new blocks and re-add any of the missing template blocks. The same is also true if you use templateLock={ false }.
To Reproduce
Steps to reproduce the behavior:
Create a basic InnerBlocks with a template that can be found here InnerBlocks.
Once you have a custom block template add it to the editor and insert or remove a template block. Next update the page/post and refresh the editor.
Expected behavior
I expected that an unlocked template would keep it's current state upon save / editor refresh if a block has been added or removed instead of reverting back to the original template.
Screenshots
Before New Content
Newly Added Content
After Save
Desktop (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: