navbar toggles all menus

Created on 30 July 2025, 2 months ago

Problem/Motivation

The navbar toggle uses '.navbar-collapse' as a selector value for its data-bs-target attribute, which is a class name already used by Bootstrap. So, any other Bootstrap-enabled menu on the page (with that class) will be controlled by the main menu toggle.

Steps to reproduce

β€’ Create a page with items added to the Drupal Main menu, and add this menu to one of the navbar regions.
β€’ Add a menu elsewhere according to example code from the Bootstrap documentation.
β€’ Toggle the Drupal Main menu "hamburger" button.

Expected result: Drupal Main menu is expanded, other menu is unaffected.
Actual result: Both menus expand and collapse as the Drupal Main menu "hamburger" button is toggled.

Proposed resolution

Instead, the data-bs-target attribute should use a selector with an id attribute that is a name unique to the navbar it controls (which should have the same unique value for its id attribute).

Patch(s) change the '.navbar-collapse' selector to '#header-navbar' and adds this id to the div with the class '.navbar-collapse'

πŸ› Bug report
Status

Needs review

Version

6.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kroh San Antonio, TX

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

Comments & Activities

Production build 0.71.5 2024