Hoping for something cleaner and less error prone, but here's what I do:
Wrap the snippet with your navigation list(s) in a container, add class navlistwrapper and in the common tab name it for example containerFoo (start always with "container"), which Mendix translates to class mx-name-containerFoo.
Give every navigation list item caption a name starting with "text" corresponding to the wrapper container on its page, for example textFoo, wich then translates to a class mx-name-textFoo.
Below the navigation list, add a snippet (reusable) with an Event calling a nanoflow calling a javascript action which searches for navlistwrapper, takes the part after it's class mx-name-container... (e.g. "Foo") and highlights the item with with corresponding class mx-name-textFoo:
const wrappers = document.getElementsByClassName('navlistwrapper');
[].forEach.call(wrappers, function(wrapper) {
const classNames = wrapper.classList;
classNames.forEach(name => {
if (name.startsWith("mx-name-container")){
var targetClass = "mx-name-text" + name.substring(17);
const target = wrapper.getElementsByClassName(targetClass)[0];
// the line below will throw an error if target === undefined, which is good
target.classList.add("text-bold", "text-primary");
}
})
})
Also curious to hear how others are dealing with this