Problem/Motivation
Radix v6 runs afoul of a core bug. In radix, the local tasks are displayed using the nav-item component. nav-item.twig contains:
{{ link|add_class('nav-link', is_active ? 'active' : '') }}
The problem arises when visiting the page for a secondary local task. Core add a "is-active" CSS class to the link in the primary tab, using $element['#options']['attributes']['class']
, as is standard for a link render element.
However the above add_class()
twig filter add the 'nav-link' (and possibly 'active') classes to $element['#attributes']
. The Link render element combines these attributes, but (incorrectly) does not merge the classes. The result is a loss of the classes added via twig for the active primary tab.
I have posted a patch in the parent issue to fix this in core. To avoid this issue in radix, you could unset the classes in #options in a preprocess function for local tasks primary and secondary. Still, there could be other uses of the nav-link component which would trigger the issue
Steps to reproduce
Create a page with primary and secondary local tasks. Visit a page for a secondary tasks. Observe that the primary tab is displayed without the "nav-link" class.
Proposed resolution
Option 1: Document that the patch in the related issue be installed when using radix v6 if you have secondary local tasks.
Option 2: Move the attributes from $element['#options']['attributes']
to $element['#attributes']
in a preprocess function for local tasks (primary and secondary).