Active menu item not showing as title if it has no children

Created on 8 April 2021, over 3 years ago
Updated 11 May 2024, 7 months ago

Problem/Motivation

The active menu item is not showing as title if it has no children if we set initial visibility level to 2, despite we set the Active's trail root title or the Active item's title to be used as title. The block title is showing instead.

Steps to reproduce

Configure a Menu block with:

  • "Display title" enabled.
  • Initial visibility level = 2.
  • Number of levels to display = "unlimited".
  • Use as title = "Active's trail root title" (or "Active item's title")

Configure a menu item which does not have children, or all of its children are disabled. Place the block in that page.

When visiting the page the block shows the title of the block, not the active item (which in this case would be also the active's trail root title).

Proposed resolution

Looking at the code, the lines where the label is set to be used is under a condition ($build must have a #theme set) that is not true when the active item has no children. I think we should remove that condition or replace it but what is really needed to check there, if any. I believe $build['#theme'] is not needed, and it's actually overriden within the condition block.

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇪🇸Spain juanolalla

Live updates comments and jobs are added and updated live.
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.

Production build 0.71.5 2024