Description
When using templateLock: "contentOnly" within a Group block (in a template part, for example), the editor correctly restricts structural changes but incorrectly displays "Add before", "Add after", and "Duplicate" options in the block options (three vertical dots) menu for child Paragraph blocks.
While "Duplicate" works (which is arguably a structural change), "Add before" and "Add after" do nothing when clicked, leading to a broken user experience.
Expected behavior:
According to the documentation, users should only be able to edit the content. The "Add before/after" options should be hidden entirely, as adding new blocks (even if they are the same type) changes the layout/structure defined by the template.
Actual behavior:
- The options are visible in the menu.
- "Add before" and "Add after" fail silently (no action taken).
- "Duplicate" works, which bypasses the intended restriction of the template lock.
Step-by-step reproduction instructions
- Create a template part or a block pattern.
- Wrap content in a Group block with the attribute
"templateLock": "contentOnly" and the attribute "lock":{"move":true,"remove":true}.
- Include a Paragraph block inside this group.
- In the Site Editor, select the Paragraph block.
- Click the "Options" (three vertical dots) menu in the block toolbar.
- Observe that "Duplicate", "Add before", and "Add after" are visible.
- Click "Add before" or "Add after". Note that no block inserter appears and no block is added.
Screenshots, screen recording, code snippet
This is the code of the template part I used to test this:
<!-- wp:group {"style":{"spacing":{"margin":{"top":"20px","bottom":"20px"}}},"layout":{"type":"constrained"},"templateLock":"contentOnly","lock":{"move":true,"remove":true}} -->
<div class="wp-block-group" style="margin-top:20px;margin-bottom:20px"><!-- wp:columns {"style":{"spacing":{"blockGap":{"left":"50px"}}}} -->
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:site-title {"level":0} /-->
<!-- wp:paragraph -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<!-- /wp:paragraph --></div>
<!-- /wp:column -->
<!-- wp:column -->
<div class="wp-block-column"><!-- wp:page-list /--></div>
<!-- /wp:column -->
<!-- wp:column -->
<div class="wp-block-column"><!-- wp:social-links {"iconBackgroundColor":"black","iconBackgroundColorValue":"#000000","openInNewTab":true,"className":"is-style-default","style":{"spacing":{"blockGap":{"left":"5px"}}}} -->
<ul class="wp-block-social-links has-icon-background-color is-style-default"><!-- wp:social-link {"service":"instagram"} /-->
<!-- wp:social-link {"service":"facebook"} /-->
<!-- wp:social-link {"service":"x"} /--></ul>
<!-- /wp:social-links -->
<!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"theme/privacy"}}}} -->
<p></p>
<!-- /wp:paragraph --></div>
<!-- /wp:column --></div>
<!-- /wp:columns --></div>
<!-- /wp:group -->
Screenshot showing the issue:
Environment info
- WordPress version: 7.0 RC2
- Gutenberg plugin: No Gutenberg plugin active
- Theme: Custom hybrid theme
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
Description
When using
templateLock: "contentOnly"within a Group block (in a template part, for example), the editor correctly restricts structural changes but incorrectly displays "Add before", "Add after", and "Duplicate" options in the block options (three vertical dots) menu for child Paragraph blocks.While "Duplicate" works (which is arguably a structural change), "Add before" and "Add after" do nothing when clicked, leading to a broken user experience.
Expected behavior:
According to the documentation, users should only be able to edit the content. The "Add before/after" options should be hidden entirely, as adding new blocks (even if they are the same type) changes the layout/structure defined by the template.
Actual behavior:
Step-by-step reproduction instructions
"templateLock": "contentOnly"and the attribute"lock":{"move":true,"remove":true}.Screenshots, screen recording, code snippet
This is the code of the template part I used to test this:
Screenshot showing the issue:
Environment info
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.