Skip to content

Allow overriding the templateLock of existing blocks #9386

Closed
@haszari

Description

@haszari

Is your feature request related to a problem? Please describe.
We're using templates to implement reusable chunks of layout for landing pages. For example, a call-to-action header block with two columns containing heading, text, an image, a button, and some custom styling.

Templates are really powerful and convenient for this purpose, but there are quirks that are causing problems for us:

  • It's hard to navigate nested blocks. In particular, it's very easy to add new blocks inside another block's outer container (and it's conversely hard to add things to the top-level page).
  • When containers allow editing, a placeholder core/paragraph block is added, which is not needed for our layouts, and causes issues on the front end.

To work around these issues, we're looking at locking all our template blocks for now using templateLock. This will reduce the flexibility of the blocks, but will make things much simpler and more predictable for our authors.

This works well most of the time. However, when a template contains columns, the columns block overrides templateLock locally. This is frustrating, because the extra placeholder paragraph appears again, breaking the layout, and allowing accidental insertion of a template within a template!

Describe the solution you'd like
Since we are instantiating the columns blocks (and their children) directly within our template, it seems appropriate that we could instruct them to not allow editing. If core/columns had a forceLock attribute, which inhibited the override, we could set this as needed in our templates.

Describe alternatives you've considered
Would love to hear other ideas for how to work around this. Here are some ideas:

  • Implement our own custom columns block, and not use core/columns block.
  • Implement our columns as markup directly in our template blocks, and use multiple template/InnerBlocks. (Is this possible?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Templates APIRelated to API powering block template functionality in the Site Editor[Priority] LowUsed to indicate that the issue at hand isn't a top priority to address and can be handled later[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions