Navigation > Nested menu isOpen() vs. "current"

Hi forum,

I’m using the wonderful nested menu from the Kirby docs and replaced the CSS current class with a more accessible aria-current attribute.

<li><a<?php e($item->isOpen(), ' aria-current="page"') ?> href="<?= $item->url() ?>"><?= $item->title()->html() ?></a> 

Given that the user tries to navigate thru the nav tree and comes to a sub-item there are now TWO aria-current attributes. The parent element (which is not exactly “current” and current child.

Screenshot with highlighted “current” page(s):

a[aria-current] { font-weight: bold; }

Is there a way of addressing only the one current page?

Thanks for your help!

There are two methods:

  • isOpen() refers to the current page or its parents
  • isActive() refers to the actually visible page
1 Like