When a menu is rendered in the ul tag we can easily find the nav and menu class what is practical to use to target our styles; however if we need to target specific styles to specific menus we don't have the posibility to target that concrete menu.

In the template "templates/menu/menu.html.twig" the menu_name value is available but not included in the macro.

This is a patch that includes the menu machine name as attribute and will help with this need.

Comments

casivaagustin created an issue. See original summary.

casivaagustin’s picture

bandanasharma’s picture

Status: Active » Needs review
bandanasharma’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
30.45 KB
25.36 KB

#2 patch is apply successfully. I have attached the after and before attachment.

markcarver’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -CSS, -markup
+++ b/templates/menu/menu.html.twig
@@ -21,15 +21,15 @@
+      <ul{{ attributes.addClass('menu', 'nav', menu_name) }}>
...
+      <ul{{ attributes.addClass('dropdown-menu', menu_name) }}>

Since this is a variable (machine name), then it should use the |clean_class filter as well when adding it.

markcarver’s picture

@bandanasharma, taking screenshots of code changes isn't necessary and honestly, a little confusing; that is what the patch is for.

Screenshots are typically only useful for changes that affect the UI/site itself.

casivaagustin’s picture

Here goes a patch for the comment #6.

casivaagustin’s picture

Status: Needs work » Needs review
casivaagustin’s picture

Bump: Ready for Review