Commit 5f092913 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

Issue #3276618 by catch, mherchel, eojthebrave, Gábor Hojtsy: Olivero sets...

Issue #3276618 by catch, mherchel, eojthebrave, Gábor Hojtsy: Olivero sets inconsistent classes for active trail between menu and book
parent a9119bc7
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -29,9 +29,14 @@ protected function assertMenuActiveTrail($tree, $last_active) {
      $i = 0;
      foreach ($tree as $link_path => $link_title) {
        $part_xpath = (!$i ? '//' : '/following-sibling::ul/descendant::');
        $part_xpath .= 'li[contains(@class, :class)]/a[contains(@href, :href) and contains(text(), :title)]';
        $part_xpath .= 'li[contains(@class, :classy-class-trail) or contains(@class, :olivero-class-trail)]/a[contains(@href, :href) and contains(text(), :title)]';
        // These active trail classes are added by classy/olivero. This should
        // be refactored to work with stark and not depend on any specific
        // theme.
        // https://www.drupal.org/project/drupal/issues/3276652
        $part_args = [
          ':class' => 'menu-item--active-trail',
          ':classy-class-trail' => 'menu-item--active-trail',
          ':olivero-class-trail' => 'menu__item--active-trail',
          ':href' => Url::fromUri('base:' . $link_path)->toString(),
          ':title' => $link_title,
        ];
@@ -48,9 +53,10 @@ protected function assertMenuActiveTrail($tree, $last_active) {
      $xpath .= '//';
    }
    $xpath_last_active = ($last_active ? 'and contains(@class, :class-active)' : '');
    $xpath .= 'li[contains(@class, :class-trail)]/a[contains(@href, :href) ' . $xpath_last_active . 'and contains(text(), :title)]';
    $xpath .= 'li[contains(@class, :classy-class-trail) or contains(@class, :olivero-class-trail)]/a[contains(@href, :href) ' . $xpath_last_active . 'and contains(text(), :title)]';
    $args = [
      ':class-trail' => 'menu-item--active-trail',
      ':classy-class-trail' => 'menu-item--active-trail',
      ':olivero-class-trail' => 'menu__item--active-trail',
      ':class-active' => 'is-active',
      ':href' => Url::fromUri('base:' . $active_link_path)->toString(),
      ':title' => $active_link_title,
+3 −4
Original line number Diff line number Diff line
@@ -38,11 +38,10 @@
      {%
        set item_classes = [
          'book-navigation__item',
          'menu-item',
          'menu__item--level-' ~ (menu_level + 1),
          item.is_expanded ? 'menu-item--expanded',
          item.is_collapsed ? 'menu-item--collapsed',
          item.in_active_trail ? 'menu-item--active-trail',
          item.is_expanded ? 'menu__item--expanded',
          item.is_collapsed ? 'menu__item--collapsed',
          item.in_active_trail ? 'menu__item--active-trail',
        ]
      %}
      {% set link_classes = [