I'm trying to implement correct highlight condition for route links in nested layouts.
I have the following page which has the following layout structure:
1 - route link in MainLayout
2 - route link in CandidatesLayout
3 - route link in CandidateLayout
As you may see - 1 and 2 links are not highlighted but I need to highlight them also.
I added the following code to each route link:
link.setHighlightCondition(buildHighLightConditionFor(navigationTarget));
public static HighlightCondition<RouterLink> buildHighLightConditionFor(Class<?> linkTargetClass) {
return (link, afterNavigationEvent) -> {
return afterNavigationEvent
.getActiveChain()
.stream()
.anyMatch(element -> {
return element.getClass() == linkTargetClass;
});
};
}
I did this because I have a Route with @RouteAlias("") as described here https://cookbook.vaadin.com/highlight-link-with-default-route/about
How to extend this code in order to highlight 1 and 2 route links in parent layouts?
UPDATED
@Route(value = "candidates/:profileUuid", layout = CandidateLayout.class)
@AnonymousAllowed
