Skip to content

Block API: Change block mutation functions from undefined to noop in locked template #6587

Open

Description

Previously: https://github.com/WordPress/gutenberg/pull/3686/files#r185262287

Currently, a block implementer may need to anticipate that any of the following functions may be undefined if the post template is locked for editing:

  • insertBlocksAfter
  • onReplace
  • mergeBlocks

Instead of placing the burden on the developer to differentiate between the type, we should simply pass it as a function regardless of whether the template is locked. If it is a locked template, the function should effectively be a noop.

Open questions:

  • Are there valid use cases where a block implementer may legitimately want to distinguish characteristics of the block depending on whether the template is locked or not? This information is still available via withSelect, and could additionally be passed as a prop to the block's edit component.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Developer ExperienceIdeas about improving block and theme developer experienceIdeas about improving block and theme developer experience[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Priority] LowUsed to indicate that the issue at hand isn't a top priority to address and can be handled laterUsed to indicate that the issue at hand isn't a top priority to address and can be handled later[Type] TaskIssues or PRs that have been broken down into an individual action to takeIssues or PRs that have been broken down into an individual action to take

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions