Remove overview menu items or make them optional

Created on 25 November 2022, over 2 years ago
Updated 4 June 2024, 11 months ago

Problem/Motivation

In vertical mode, "Overview" items are added. These seem redundant as the parent item is visible with the same link.

Steps to reproduce

Set toolbar in vertical mode.

Proposed resolution

Remove the "Overview" items, or make it configurable so we can turn them of using settings.

✨ Feature request
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium kriboogh

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.

  • πŸ‡ΊπŸ‡ΈUnited States rishi kulshreshtha

    Given the specific requirement to hide elements containing the word "Overview," it seems that CSS may not be the most suitable solution. Instead, I successfully accomplished this task using jQuery:

    (function ($, Drupal) {
      Drupal.behaviors.hideMenuOverview = {
        attach: function (context, settings) {
          // CSS selector for the menu item.
          const menuSelector = '.menu-item__menu_link_content\\:7c45b7f1-64a6-4700-86f1-9216ee8d78ee';
          $(once('hide-menu-item-overview', menuSelector, context)).each(function () {
            // Find child element(s) within the menu item that contain "Overview"
            // text.
            const childElement = $(this).find('a:contains("Overview")');
    
            // Hide the child element(s)
            childElement.hide();
          });
        }
      };
    })(jQuery, Drupal);
    
    
  • πŸ‡ΊπŸ‡ΈUnited States justcaldwell Austin, Texas

    In case it's helpful to anyone wanting to take the CSS approach, this did the trick for me:

    .gin--vertical-toolbar .toolbar-menu .toolbar-menu > .menu-item:nth-child(2) {
        display: none;
    }

    It feels a bit more fragile than I'd like. It would be nice if those 'Overview' items had a classname β€” e.g. 'gin-overview' or some such.

  • πŸ‡³πŸ‡±Netherlands koosvdkolk

    @justcaldwell: Thanks for your solution. I agree with your suggestion: menu items should have a unique reference for both their route and their location within the menu.

    I ended up with using the 'href' as a pseudo-classname:

    E.g to target 'Overview' in the 'Add content' sub menu:

    .gin--vertical-toolbar .toolbar-menu .toolbar-menu .toolbar-menu li > a[href="/node/add"] {
      border: 1px solid red !important;
    }
    
Production build 0.71.5 2024