Skip to content

ContentOnly Patterns experiment: Update the categories metadata attribute consistently alongside patternName #71687

@talldan

Description

@talldan

Part of #71517

What problem does this address?

When inserting any pattern with a category from the main inserter sidebar, the inserted block usually has a few metadata attributes set, for example here's a pattern from TT5:

{
  "metadata": {
    "categories":["about"],
    "patternName":"twentytwentyfive/banner-cover-big-heading",
    "name":"Cover with big heading"
  }
}

As part of the contentOnly patterns experiment, there are a few places where patternName is added, but categories isn't added (or isn't added correctly). The consistency around how that works could be improved. Here's some examples:

  • When using the "Create pattern" option on a block to convert it to an unsynced pattern (link)
  • The slash inserter - the categories attribute is added but the category values are ids and not slugs (link)

Similarly, another consideration is whether the categories attribtute should be removed when a pattern is detached:

  • Edit contents button (link)
  • Detach menu item (link)

One of the reasons this wasn't addressed originally is that it's not clear what categories is for, so it'd be good to discover that first. Also, sometimes the id is used and sometimes the slug (even for the same pattern and category inserted from different places), so that needs to be understood. @aaronrobertshaw dropped a couple of links to relevant issues in a previous conversation:

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.
    No fields configured for Enhancement.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions