Plugin Author
malihu
(@malihu)
Hello,
The issue you describe should not be related to the option you’ve enabled. There’s a chance that it’s related to some other script in your theme or a conflict with some other option.
The option that should be enabled is “Keep the current element highlighted until the next one comes into view”. Is it enabled?
The thing is that I can’t really help unless I see your page. Maybe you can send me your URL?
Thread Starter
pip24
(@pip24)
Hi, thanks for your reply. Unfortunately I can’t send the URL. Due to client confidentiality I’m hosting it offline. Maybe I can create a quick sample page if necessary?
When I enable “Keep the current element highlighted until the next one comes into view” it doesn’t highlight any sub-item when there is no section with anchor point within the viewport. What is the option “Highlight by next target” supposed to do?
I added one custom script for the vertical menu. Is it possible that the issue is caused by this script?:
<script type="text/javascript">
/* Collapse Vertical Menu */
(function($){
function collapse_vertical_menu_submenus() {
// keep submenu open if it has an active item
$('.sub-menu .current-menu-item').parents('.sub-menu').show();
var $menu = $('#top-menu'),
top_level_link = '#top-menu .menu-item-has-children > a';
$menu.find('a').each(function() {
$(this).off('click');
if ( $(this).is(top_level_link) ) {
$(this).attr('href', '#');
}
if ( $(this).siblings('.sub-menu').length ) {
$(this).on('click', function(event) {
event.preventDefault();
current_submenu = $(this).siblings('.sub-menu');
current_submenu_parents = current_submenu.parents('.sub-menu');
$(this).parents('#top-menu').find('.sub-menu').not(current_submenu_parents).not(current_submenu).slideUp();
$(this).siblings('.sub-menu').slideToggle();
});
}
});
}
$(window).load(function() {
collapse_vertical_menu_submenus();
});
})(jQuery);
</script>
Plugin Author
malihu
(@malihu)
No, the issue should not be related to your script.
“Highlight by next target” option keeps the link highlighted only by its next adjacent element/section.
Do you have “Allow only one highlighted element at a time” option enabled? If yes, disable it.
Plugin Author
malihu
(@malihu)
Also, is there a chance your link has a CSS animation attached, causing the issue?
Thread Starter
pip24
(@pip24)
No, I don’t have enabled that option.
Thread Starter
pip24
(@pip24)
I created a quick sample page with parts of the same css code I used in the other page and I’m having the same issue:
Sample Webpage
When opening Menu-item 2 and then click on Item 1: the first sub-item is highlighted.
When scrolling to the header Item 1 (2) the first sub-item is still highlighted. However, when you stop scrolling the highlight of the sub-menu item fades out.
I hope you understand what I mean?
Besides, the last submenu-item Menu-item 3 is highlighted with a delay and only when not scrolling..
Plugin Author
malihu
(@malihu)
I just saw that in plugin settings, you changed the highlight class name in “Classes & highlight options” to mPS2id-highlight-first.
Change it back to the default mPS2id-highlight`, save changes and let me know.
Plugin Author
malihu
(@malihu)
Also, enable “Keep the current element highlighted until the next one comes into view” option and disable “Highlight by next target” option.
Thread Starter
pip24
(@pip24)
I changed the class name and options. Now item 1 is not highlighted anymore when you scroll to header item 1 (2) because this header is not part of the section with the anchor point.
Plugin Author
malihu
(@malihu)
OK. Now try setting the “Highlight selector(s)” option value to:
#top-menu-nav .menu-item a
Thread Starter
pip24
(@pip24)
Yes, it works! Thank you very much!!
Thread Starter
pip24
(@pip24)
Still one problem.. When I scroll up from the bottom of the page to the top of the page Item 2 keeps highlighted (instead of Item 1 when header Item 1 (2) is within the viewport.
Plugin Author
malihu
(@malihu)
I see. This is a limiting factor when you have mixed sections and there’s no really a turnaround for it. With the same settings as you have now, try enabling “Highlight by next target” option and let me know.
Thread Starter
pip24
(@pip24)
Thanks, it works! However, the weird thing is that I copied the exact settings to the actual website, and there it still goes wrong..
The differences:
With highlighted menu-item
Actual page
<a href="/handleidingtechnicus/#inleiding" aria-current="page" data-ps2id-api="true" data-et-has-event-already="true" class="_mPS2id-h mPS2id-highlight">Inleiding</a>
Sample page
<a href="/Menu-item-2/#item-1" aria-current="page" data-ps2id-api="true" data-et-has-event-already="true" class="__mPS2id _mPS2id-h mPS2id-highlight mPS2id-highlight-first mPS2id-highlight-last">Item 1</a>
Without highlighted menu-item
Actual page
<a href="/handleidingtechnicus/#inleiding" aria-current="page" data-ps2id-api="true" data-et-has-event-already="true" class="_mPS2id-h">Inleiding</a>
Sample page
<a href="/Menu-item-2/#item-1" aria-current="page" data-ps2id-api="true" data-et-has-event-already="true" class="__mPS2id _mPS2id-h">Item 1</a>
Does this make any sense?
Plugin Author
malihu
(@malihu)
If it doesn’t work on the actual site, is because the sections are different (i.e. there’s a mix between wrapped and unwrapped sections with varying elements between sections). I don’t know if this can work well. I think it’s better to just copy/paste your divi modules inside a divi row and give it the id you want.