Add active-trail class to menu
That happens automatically, at least by default for themes inheriting from Classy. See https://api.drupal.org/api/drupal/core%21themes%21classy%21templates%21navigation%21menu.html.twig/8:

  {%
    set classes = [
      'menu-item',
      item.is_expanded ? 'menu-item--expanded',
      item.is_collapsed ? 'menu-item--collapsed',
      item.in_active_trail ? 'menu-item--active-trail',
    ]
  %}
  &lt;li{{ item.attributes.addClass(classes) }}&gt;


So, make sure you are inheriting from Classy (recommended) or duplicate some of this logic in your theme.