Custom blocks missing if two modules/themes declare the same category

Created on 15 August 2024, 4 months ago
Updated 30 August 2024, 4 months ago

Problem/Motivation

Currently if you have two modules or themes defining blocks in the mymodule.gutenberg.yml file using the same category reference, the later processed module will overwrite the blocks of the first one. Essentially you will not be able to make custom blocks of the first module with the same category available at all.

It would be good if multiple modules/themes could add blocks for example to the "Layout" category.

Currently it behaves the following.

mymodule_a.gutenberg.yml

custom-blocks:
  categories:
    - reference: layout # The category where the block will be added.
      name: Layout
      blocks:
        - id: custom-card-block/custom-card-block
          name: Custom Card Block

mymodule_b.gutenberg.yml

custom-blocks:
  categories:
    - reference: layout # The category where the block will be added.
      name: Layout
      blocks:
        - id: custom-example-block/custom-example-block
          name: Custom Example Block

Then the custom blocks from mymodule_a will not be selectable in the node type form and therefore cannot be used in Gutenberg.

Steps to reproduce

Proposed resolution

If a category reference was already defined then the blocks of mymodule_b should merge into the existing category, so that all blocks can be configured and enabled/disabled.

It of course would not solve, if a the second module defines a different name for the category, but I think that's a minor problem compared to the real-life problem described above.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇩🇪Germany szeidler Berlin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @szeidler
  • Status changed to Needs review 4 months ago
  • 🇩🇪Germany szeidler Berlin

    I created a pull request that is now merging the blocks together, if a category of mymodule_b is processed and the same category reference from mymodule_b already exists.

    Furthermore – since I have been touching the code anyhow – I renamed the foreach $theme_definition to $definition to be precise, because it's actually the merged together definitions from themes and modules.

  • Status changed to Fixed 4 months ago
  • 🇩🇪Germany szeidler Berlin

    szeidler changed the visibility of the branch 3468393-custom-blocks-missing-2.x to hidden.

  • 🇩🇪Germany szeidler Berlin

    szeidler changed the visibility of the branch 3468393-custom-blocks-missing-2.x to active.

  • Pipeline finished with Success
    4 months ago
    #255699
  • Pipeline finished with Skipped
    4 months ago
    #255711
  • Pipeline finished with Skipped
    4 months ago
    #255712
    • szeidler committed 64e66c45 on 8.x-2.x
      Issue #3468393 by szeidler, marcofernandes: Custom blocks missing if two...
  • Pipeline finished with Failed
    4 months ago
    Total: 505s
    #260260
  • Pipeline finished with Skipped
    4 months ago
    #260575
  • Pipeline finished with Canceled
    4 months ago
    Total: 175s
    #261493
  • Pipeline finished with Success
    4 months ago
    Total: 321s
    #261494
  • Pipeline finished with Canceled
    4 months ago
    Total: 274s
    #262385
  • Pipeline finished with Success
    4 months ago
    Total: 3188s
    #262394
  • Pipeline finished with Failed
    4 months ago
    Total: 695s
    #267555
  • Pipeline finished with Failed
    4 months ago
    Total: 555s
    #268029
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Pipeline finished with Success
    2 months ago
    Total: 207s
    #311552
  • Pipeline finished with Canceled
    2 months ago
    Total: 79s
    #311562
  • Pipeline finished with Success
    2 months ago
    Total: 1590s
    #311563
  • Pipeline finished with Success
    2 months ago
    Total: 158s
    #311592
  • Pipeline finished with Success
    2 months ago
    Total: 509s
    #312359
  • Pipeline finished with Success
    2 months ago
    Total: 342s
    #312667
  • Pipeline finished with Skipped
    about 1 month ago
    #339730
  • Pipeline finished with Failed
    about 1 month ago
    Total: 339s
    #349455
  • Pipeline finished with Failed
    about 1 month ago
    Total: 334s
    #349483
  • Pipeline finished with Failed
    about 1 month ago
    Total: 342s
    #349511
  • Pipeline finished with Success
    28 days ago
    Total: 328s
    #352805
  • Pipeline finished with Success
    28 days ago
    Total: 339s
    #353342
  • Pipeline finished with Success
    27 days ago
    Total: 228s
    #354047
  • Pipeline finished with Success
    21 days ago
    Total: 215s
    #360631
  • Pipeline finished with Failed
    8 days ago
    Total: 51s
    #372254
  • Pipeline finished with Success
    8 days ago
    Total: 51s
    #372263
Production build 0.71.5 2024