Setting Use as title to "Active trail's root title" should respect Initial visibility level

Created on 16 November 2022, over 2 years ago
Updated 7 June 2023, almost 2 years ago

Problem/Motivation

Currently there is no way to set the block's title to the parent of the initial visibility level when this is set higher than level 2.
This is to me the expected behaviour when using "Active trail's root title", since the parent of the configured visibility level is the Active trail's root, however when is actually used is the 1st level item of the Active trail

Steps to reproduce

  1. Create a menu with the structure:
    • Food
      • Vegetables
      • Grains
        • Wheat
        • Barley
    • Drink
    • Equipment
  2. Add a menu block that will appear on the and pages with configured as 3 and configured as "Active trail's root title"
  3. Navigate to the or page
  4. Observe that the menu block contains and , but that the title is rather than

I don't imagine this is super useful to most people.

Proposed resolution

Update "Active trail's root title" to use the immediate parent of the visibility level rather than the 1st level item of the current trail. Have a patch ready for this.

An alternative approach would be to add a new option such as "Visible trail root" to avoid the situation where someone is intentionally using the current behaviour with a gap the trail (IMO this is unlikely, but people do their own thing).

Remaining tasks

Updated code has not yet been tested with "Make the initial visibility level follow the active menu item" option checked.

User interface changes

Menu Blocks with "Active trail's root title" set will display the parent of the visible portion of the active menu trail as the block title instead of the 1st level item in the trail as is used now.

API changes

None

Data model changes

In-memory only: Add a protected $menuRoot property to the Drupal\menu_block\Plugin\Block to propagate the $menu_root id from the build() method to the getActiveTrailRootTitle() method.

Feature request
Status

RTBC

Version

1.0

Component

Code

Created by

🇦🇺Australia Agileware

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

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024