Problem/Motivation

Any menu block should function in the primary menu region, but custom menus don't behave like the primary menu when placed in this region. I've tested with Barrio and Barrio Subtheme and the behavior is the same in both themes, so it does not appear to be a subtheme issue.

Steps to reproduce

  1. Install Bootstrap Barrio.
  2. Create a new menu at admin/structure/menu/add.
  3. Add multiple links to the menu.
  4. Move a link beneath a parent, and set the parent link to "expanded."
  5. Put the menu block in the theme's primary menu region. The whole menu shows as expanded instead of showing a dropdown for the parent.

Proposed resolution

Not sure

Remaining tasks

Not sure

User interface changes

Not sure

API changes

Data model changes

CommentFileSizeAuthor
#2 2021-11-22 14_46_33-Window.png3.97 KBElToundriko

Comments

potassiumchloride created an issue. See original summary.

ElToundriko’s picture

StatusFileSize
new3.97 KB

Hello,

Same issue here with bootstrap_barrio 5.5.4 on Drupal 9.2.9.

Steps to reproduce:

  1. Install drupal/bootstrap_barrio with composer
  2. Create a custom module
  3. Add a mymodule.links.menu.yml with sub-level entries (see below)
  4. Place menu block in main menu region

Result:
the UL bubbles are visible. (see attachment)

Code inside mymodule.links.menu.yml :

### REDACTEURS ###

# titre actualités pour sous-menu
redacteurs.actualites:
  title : 'Actualités'
  route_name: <none>
  parent: main
  menu_name: redacteurs
  weight: 1

# lien vers les actualités pour les rédacteurs
redacteurs.entity.actualite.collection:
  title: 'Liste'
  route_name: entity.actualite.collection
  description: 'Liste des actualités'
  parent: redacteurs.actualites
  menu_name: redacteurs
  weight: 0

# lien vers la création d'une actualité pour les rédateurs
redacteurs.entity.actualite.create:
  title: 'Créer'
  route_name: entity.actualite.add_form
  description: 'Créer une nouvelle actualité'
  parent: redacteurs.actualites
  menu_name: redacteurs
  weight: 1
hatuhay’s picture

Category: Bug report » Support request

The new menu at least should have same structure/markup as the original main menu

ElToundriko’s picture

Category: Support request » Bug report

Thanks to your advice, it now works ! I noticed from twig debug mode that the template loaded was menu.html.twig.

Here is what I've done :

  1. copy /themes/contrib/bootstrap_barrio/templates/navigation/menu--main.html.twig to /themes/custom/mytheme/templates
  2. rename file to menu--mymenu.html.twig, where mymenu is the name of the new menu
  3. drush cache:rebuild
  4. check that menu--mymenu.html.twig is now used for templating

Thank you @hatuhay , hope it helps the reporter of the bug.

hatuhay’s picture

Category: Bug report » Support request
Status: Active » Closed (works as designed)

This is not a bug, please do not recategorize this.

potassiumchloride’s picture

Thanks @hatuhay and @ELToundriko.

I followed these steps

copy /themes/contrib/bootstrap_barrio/templates/navigation/menu--main.html.twig to /themes/custom/mytheme/templates
rename file to menu--mymenu.html.twig, where mymenu is the name of the new menu
drush cache:rebuild
check that menu--mymenu.html.twig is now used for templating

And now my new subtheme does have a mymenu and top level items display the dropdown carrot. That is excellent.

However, the mymenu had the same problem as Issue 3223479 where the dropdown did not work. I was baffled because I copied the twig file (as outlined in #1 above) from Barrio 5.5.4, and I'm using the main menu in the site's default subtheme and that main menu works properly there.

Investigation showed that if the Load Library settings at /admin/appearance/settings/newsubtheme are set to any CDN or other library other than -None- then the dropdown menu for mymenu does not work in that new subtheme. This is not true for the main menu, which is displayed in the default subtheme that uses a Bootswatch library. If I set the Load Library to -None- in this new subtheme, then the custom mymenu dropdowns work.

Any ideas as to why loading a library in the new subtheme would prevent the mymenu from working, when using a library in the default subtheme with the main menu does work?

potassiumchloride’s picture

Update: The libraries in the /subtheme folder in the barrio module are not the same version of Bootstrap as the libraries in the bootstrap_barrio.libraries.yml file. Changing the Bootstrap version to be the same in both bootstrap_barrio.libraries.yml and bootstrap_barrio_SUBTHEME.libraries.yml worked and the drop-down menu works with a CDN.