How to keep collapsed navigation's tree opened on current post

Hello!
I’ve created mobile a mobile menu using navigation collapsed element.
When I click some menu item - browser redirects me to the page what I need, but when I open menu I don’t see current page’s menu item because the menu collapsed.
What I expect is when I on page that has menu item in the mobile menu this menu item should has active state and menu tree should be opened so I see where in menu I’m.
Thank in advance.

Hi there,

You can achieve that with some custom CSS code.

Please try this in the Global CSS:

.x-navbar .current-page-parent .sub-menu {
    display: block;
}

Hope this helps.

Thanks for you reply!

I’ve applied custom CSS, but now I have all sub menus opened and I can’t collapse them. Even those that doesn’t has an ancestor’s class “current-services-ancestor”.

Can you point me out to solution?
Thanks in advance!

Hi @Zarudny

I believe this is achievable using jQuery, to do so please delete the previous CSS snippet, then add this JS snippet to (Theme Options > JS):

jQuery( document ).ready(function($) {

	jQuery('.menu-about-mobile .sub-menu .current-menu-ancestor .sub-menu').has('.x-anchor[class*="active"]').css("display", "block");

});

Thanks.

Thank Alaa!
Yes, it’s closer to aim.
The only thing that I’d like to change is not just open sub-menu which contain active link, but also show it’s child items.
One more thanks!

Hi again,

As you see this requires custom development and the above code we provided is only meant to be a guide or a starting point. For further customization or changes you will need to consult with a third party developer to continue with the custom development.

Thank you for understanding!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.