Block Menus that set to render level 2 and below, do not render in page variants Content

Created on 6 July 2023, 12 months ago
Updated 10 August 2023, 11 months ago

Problem/Motivation

When embedding a menu in a variant that uses Page Builder for layouts, if menu block setting for "Initial visibility level" is set to two or below, the menu does not render.

Note that this has been debugged by:

  1. Embedding the menu block in a region in the theme on the 'Block Layout' admin page (block renders)
  2. Setting the node display to use Layout Builder, and adding the block in Layout Builder to the node display (block renders)
  3. Enabling the Page Manager module, creating a variant that uses Layout Builder, and added the block to the variant display (block does not render)

In all three cases, the menu block settings were the same:

  • Initial visibility level: 2
  • Number of levels to display: Unlimited
  • Expand all menu links: Checked

Steps to reproduce

  1. Install Drupal Standard profile
  2. Install and enable the Page Manager module
  3. Create content, adding it in the Main Navigation menu, so that the page structure is as follows:

    - Home
      -- Page One
        ---- Page One A
        ---- Page One B
      -- Page Two
        
  4. Create a variant for nodes, that uses Layout Builder
  5. Add the Main Navigation menu to the variant in Layout Builder with the default block settings (specifically "Initial visibility level: 1") and save the variant
  6. Visit Page One, and see that the menu renders
  7. Edit the block settings in layout builder for the variant, and change "Initial visibility level" to 2, then save the variant.
  8. Re-visit Page One, and see that the menu now does not render.

Proposed resolution

At the moment, there is no proposed resolution. This bug was discovered when performing an upgrade from Drupal 9.4 (where it worked), to Drupal 9.5 (where it stopped working). Further debugging determined that the problem was arose specifically in Drupal 9.5.9, as a result of this code added to core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php:

    // Route defaults that do not start with a leading "_" are also
    // parameters, even if they are not included in path or host patterns.
    foreach ($route->getDefaults() as $name => $value) {
      if (!isset($raw_variables[$name]) && substr($name, 0, 1) !== '_') {
        $raw_variables[$name] = $value;
      }
    }

Removing this code results in the block rendering. So something in the introduction of this code, combined with something in the Page Manager module, has resulted in the bug of the menu not rendering when "Initial visibility level" is set to 2.

πŸ› Bug report
Status

Needs review

Version

4.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada Jaypan

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

Comments & Activities

Production build 0.69.0 2024