Duplicate Items in Choose Component Menu

Created on 31 March 2025, about 2 months ago

Problem/Motivation

Custom Mercury Editor templates show up under both Layout and Template groups in the Choose Component Menu/Popup. I am specifically talking about the menu/popup that shows up when you click on (+) in Mercury Editor while editing/adding content.

Steps to reproduce

Note: mercury_editor_template module must be enabled.

  • Add custom Mercury Editor templates at /admin/content/me-template
  • Edit/add content that has Mercury Editor enabled
  • Add a component by clicking on (+), and observe the component list in the menu/popup.

Proposed resolution

Relevant code/files:

mercury_editor/modules/mercury_editor_templates/src/EventSubscriber/LayoutParagraphsAllowedTypesSubscriber.php:105
layout_paragraphs/src/Controller/ChooseComponentController.php:164

In mercury_editor_template module, there is an event subscriber that adds custom Mercury Editor (ME) templates to allowed Layout Paragraph types. Layout Paragraphs module uses this information to generate an initial component list. Layout Paragraphs uses is_section property to determine whether a paragraph type is a layout or not.

Coming back to the event subscriber, it sets 'is_section' property to TRUE for all custom ME templates. So, when Layout Paragraphs is building the initial component list for the popup menu, 'in_section' property forces ME Template to be listed under the Layout group as well Template group.

To fix the issue, I basically changed line 105 in LayoutParagraphsAllowedTypesSubscriber.php to
'is_section' => $is_layout, so that the property is only set to TRUE if the custom template is also a layout.

πŸ› Bug report
Status

Active

Version

2.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States zd370

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024