Closed (fixed)
Project:
Nice Menus
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 Jan 2017 at 15:09 UTC
Updated:
6 Apr 2021 at 21:53 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
xiukun.zhou commentedHI. drupal8 have "menuparent" class
Comment #3
caspervoogt commentedI don't actually see an 'active' class being added to any menu items at all.
I do see a 'menuparent' being applied to items that have sub-items but these are also getting the 'menu-item--expanded' class even when they are not expanded.
Comment #4
caspervoogt commentedSlight correction. An "is-active" class gets added to my front page menu item link. No other menu items get an "is-active" class. My theme has nothing overriding anything remotely menu-related. I have tried it with Bartik as well - same thing.
Comment #5
ytsurkI can confirm the issue.
menu-parentmeans that the menuitem has childrens ... not that it's active.is-activeis only set on the anchor tag.Looking at the core's menu block i made a patch to get the active trail. Now the class .menu-item--active-trail is added like in other menus.
Is there a reason why nice_menus uses the
toolbar.menu_treeservice and not themenu.link_treeservice like cores' does ? This could be adapted as well.Comment #6
ytsurkHere another simplified approach, with every item expanded (like it was before).
Comment #7
ytsurkHere the final patch also respecting caching !
Comment #8
ytsurkComment #9
Huelfe commentedI just tried the patch from #7 but there is a caching problem. When I rebuild the cache and visit a page which is linked in the menu, then the visited menu item always has the class "menu-item--active-trail". When I click on other menu items, the class still belongs to the menu item, which was visited first after cache rebuild.
Comment #10
ytsurkI cannot reproduce this behavior. What cache are you using ?
I have enabled page_cache and dynamic_page_cache, running drupal 8.4.3 and also below ..
.menu-item--active-trailis appended to the active menu entry (li tag) and every parent of it..is-activeis appended only to the active menu entry (a tag).Comment #12
xiukun.zhou commentedThanks ytsurk
i have added a default config.
Comment #13
xiukun.zhou commentedComment #15
dfletcher commentedThanks patch in #7 worked great for me (from 8.x-1.0-beta2).