Rule's menu parent is set as active link for pages that are already in the menu.

Created on 23 July 2020, almost 4 years ago
Updated 15 August 2023, 11 months ago

Problem/Motivation

A rule's menu parent is set as the active link for pages that have a real menu link, but also match the rule.

Steps to reproduce

1. Create a menu as following:

  • Main Navigation
    • About Us
      • Our History

2. Add a Main Navigation menu block to the block layout:
- Initial visibility level: 1
- Number of levels to display: 4

3. Create a menu_position rule with Main Navigation > About Us as the menu parent,
and Path as the criteria, with the path rule set to `/about-us/*`

4. Create a node that provides a Menu link and set its parent to `Our History`

5. View the node.

Expectation: The menu should display with `Our History` set as parent, since the page has an actual menu entry.
From the module's README: "if a menu item for the current page's path is already included in the specified menu, the rule is skipped."

Actual Behavior: The menu is displayed with `About Us` set as parent.

Confirmation: If you disable the menu_position rule and reload the page, the menu is displayed with `Our History` set as parent.

Proposed resolution

Drupal\menu_position\Menu\MenuPositionActiveTrail::getActiveLink() should check for the existence of an active link before applying the rule.

πŸ› Bug report
Status

Needs review

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States joebot Topsham, ME

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.69.0 2024