Allow to Add child item like on core menu items

Created on 27 March 2025, 3 months ago

Problem/Motivation

Core has a 'Add child' functionality that is very handy when structuring a website. This is not the case when using the menu provided by this module.

Steps to reproduce

  • Edit a core menu and use the drop down actions on a menu items and see you have a 'Add child' action
  • Edit a group menu and use the drop down actions on a menu items and see you don't have a 'Add child' action

Proposed resolution

Copy the functionality from the core menu form.

Remaining tasks

Create MR
Review MR
Merge MR

User interface changes

Extra action 'Add child' on menu actions

API changes

None

Data model changes

None

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇧🇪Belgium tim-diels Belgium 🇧🇪

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

Merge Requests

Comments & Activities

  • Issue created by @tim-diels
  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    I'll provide a proper MR as I have the code ready but needs some review

  • 🇧🇪Belgium tim-diels Belgium 🇧🇪
  • Pipeline finished with Canceled
    3 months ago
    Total: 128s
    #458590
  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    Pipelines were already failing before but fixed own coding standards.

  • Pipeline finished with Failed
    3 months ago
    Total: 295s
    #458592
  • Status changed to Needs review 13 days ago
  • 🇪🇸Spain tuwebo

    I've just found this issue.
    Just for the record so I don't forget, I think we might need in the GroupContentMenuForm::buildOverviewTreeForm some code like:

            // Build a list of operations.
            $operations = [];
    
            if ($element->depth < $this->menuTree->maxDepth()) {
              $add_link_url = Url::fromRoute(
                'entity.group_content_menu.add_menu_link',
                [
                  'group' => $group->id(),
                  'group_content_menu' => $this->entity->id(),
                  'menu_link_content' => $link->getMetaData()['entity_id'],
                  'menu' => $this->entity->id(),
                ],
                ['query' => ['parent' => $link->getPluginId()]],
              );
              $operations = [
                'add-child' => [
                  'title' => $this->t('Add child'),
                  'weight' => 20,
                  'url' => $add_link_url,
                ],
              ];
              uasort($operations, [SortArray::class, 'sortByWeightElement']);
            }
    

    Not sure about it yet, since I am testing it in my local, which could be outdated

Production build 0.71.5 2024