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:
- Embedding the menu block in a region in the theme on the 'Block Layout' admin page (block renders)
- Setting the node display to use Layout Builder, and adding the block in Layout Builder to the node display (block renders)
- 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
- Install Drupal Standard profile
- Install and enable the Page Manager module
- 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
- Create a variant for nodes, that uses Layout Builder
- 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
- Visit Page One, and see that the menu renders
- Edit the block settings in layout builder for the variant, and change "Initial visibility level" to 2, then save the variant.
- 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.