Add contextual links to menu blocks directly instead using a hook_block_view_alter

Created on 9 December 2014, over 10 years ago
Updated 6 May 2025, 7 days ago

Problem/Motivation

Menu block contextual links are added through menu_ui_block_view_system_menu_block_alter(). The contextual links should be added directly when building the menu block instead.

Proposed resolution

Add contextual links directly when building the menu block instead of invoking block_view_alter

Remaining tasks

  1. Write a patch
  2. Review

User interface changes

None

API changes

None

Original report by yoroy β†’

Follow up from #2379083: Regression (again): Menu contextual links no longer visible in menu blocks, when block caching is enabled β†’

No contextual links to edit a menu for user created menus:

+++ b/core/modules/menu_ui/menu_ui.module
@@ -120,7 +120,7 @@ function menu_ui_block_view_system_menu_block_alter(array &$build, BlockPluginIn
   // Add contextual links for system menu blocks.
   $menus = menu_list_system_menus();
   $menu_name = $block->getDerivativeId();
-  if (isset($menus[$menu_name]) && isset($build['content'])) {
+  if (isset($menus[$menu_name])) {
     $build['#contextual_links']['menu'] = array(
πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

menu system

Created by

πŸ‡³πŸ‡±Netherlands yoroy

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024