Skip to content

WP 7.0 treats custom container blocks as patterns when templateLock is set to 'contentOnly' #76794

@Mr2P

Description

@Mr2P

Description

When I register a custom container block with templateLock set to contentOnly, WordPress treats it as a pattern.
The “Edit pattern” button appears in both the block toolbar and the Inspector.
I believe this may be related to how contentOnly mode interacts with the new unsynced patterns in WordPress 7.0.

Step-by-step reproduction instructions

The code to register a test content-only container block:

import { registerBlockType } from "@wordpress/blocks";
import { useBlockProps, useInnerBlocksProps } from "@wordpress/block-editor";

/**
 * Register the block type.
 * 'test/content-locked-container'
 */
registerBlockType("test/content-locked-container", {
  title: "Content-Only Container",
  category: "layout",
  edit: () => {
    const MY_TEMPLATE = [
      ["core/heading", { level: 3, placeholder: "Editable Heading" }],
      [
        "core/paragraph",
        {
          placeholder:
            "This text can be edited, but the block cannot be moved.",
        },
      ],
    ];

    const blockProps = useBlockProps();

    const innerBlocksProps = useInnerBlocksProps(blockProps, {
      template: MY_TEMPLATE,
      templateLock: "contentOnly",
    });

    return <div {...innerBlocksProps} />;
  },

  save: () => {
    const blockProps = useBlockProps.save();

    const innerBlocksProps = useInnerBlocksProps.save(blockProps);

    return <div {...innerBlocksProps} />;
  },
});

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress version 7.0 beta 6, 2025 theme

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] PatternsA collection of blocks that can be synced (previously reusable blocks) or unsynced[Type] EnhancementA suggestion for improvement.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    🦵 Punted to 7.1

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions