While #3228566: Support aria-current="location" for breadcrumbs → was a feature request with a narrow scope, this issue is about a flexible way to support all allowed aria-current values on a variety of elements.
I would like this module to be as flexible as possible, but preferably without the complexity of admin config forms and user-configurable element selectors. That's why I propose a declarative approach. A data-aria-current-type
attribute on a wrapper (eg. a nav or menu ul) declares the aria-current value that active links within that wrapper should get. For example: <ul class="menu" data-aria-current-type="page">...</ul>
tells the JS that active links within this ul should get a aria-current="page"
attribute.
Two theme preprocess functions take care of out-of-the-box support for menus and breadcrumbs. Other components can easily hook into this system by setting the appropriate data attribute. For instance, if you have a progress indicator on a custom multi-step wizard, just add data-aria-current-type="step"
.
This all assumes that the active link has a "is-active" class, as is built into Drupal core.
A downside of this solution is that is changes the behavior in existing installations. Currently, all <nav>
elements are targeted by the module's JS. In the proposed solution, only elements rendered by the 'menu' and 'breadcrumb' theme hooks are supported out-of-the-box. I think this is a minor issue because menus are the primary goal anyway.
Discuss.
None.
Introduction of a declarative interface using a data attribute.
None.
Closed: works as designed
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.