Module has no effect (theme based on starterkit_theme)

Created on 2 June 2023, over 1 year ago
Updated 29 November 2023, 12 months ago

Hi. First time user here. I'm using this module (2.0.0) with Drupal 10.0.9.

I created a new theme using starterkit (php core/scripts/drupal generate-theme mythemename) and cannot seem to get this module to have any effect on the output HTML.

My setup is very simple:

  • a "News" content type with automatic aliases of /news/title-nid
  • a /news page (views) which show the news items
  • a "News" menu item that I have manually created (it's not generated by views) and points to the /news page.

When I visit the "News" page (/news), the "News" menu item is highlighted as expected.
However when I visit the a news item (/news/title-nid), the menu item is not highlighted.

The module is configured to use "By Path" as a trail source, and I tested several values for the "Maximum path parts" (including 0). I emptied Drupal's cache each time.

I did notice that the homepage for the module writes "Drupal 8 - Make sure to use a "menu.html.twig" like the classy-theme (or use that as base theme, like bartik does), stable-theme and stark-theme will not add the classes that you propably will expect, see "No active trail class gets added"-issue." and I read the related issue.

However it's a 7 years-old issue and I don't know if it's still relevant for Drupal 10...

I checked the templates of my child theme, more specifically templates/navigation/menu.html.twig and here is what I see:

    {% for item in items %}
      {%
        set classes = [
          'menu-item',
          item.is_expanded ? 'menu-item--expanded',
          item.is_collapsed ? 'menu-item--collapsed',
          item.in_active_trail ? 'menu-item--active-trail',
        ]
      %}
      <li{{ item.attributes.addClass(classes) }}>
        {{ link(item.title, item.url) }}
        {% if item.below %}
          {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
        {% endif %}
      </li>
    {% endfor %}

It seems to me that the class that I need (menu-item--active-trail) is indeed present in this theme.

Classy or Bartik aren't present in Drupal 10 core any more, so I couldn't check what their templates look like.

What am I doing wrong?

💬 Support request
Status

Fixed

Version

2.0

Component

Miscellaneous

Created by

🇨🇭Switzerland s427

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

Comments & Activities

  • Issue created by @s427
  • Status changed to Fixed 12 months ago
  • 🇨🇭Switzerland berdir Switzerland

    > What am I doing wrong?

    Nothing I think.

    I don't know on top of my head, but it's quite possible that starterkit theme only adds CSS for the is-active class and not the active trail, that would be up to you to do then.

    If the active trail class is there then the module is doing what it should, without that module, I would expect that the active trail class is not present.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024