$variables['selected'] is missing for bef-links.html.twig template.
[ORIGINAL ISSUE]
I tried for hours to change the class in the link. On the 8.3 version I was able to create a simple bef-links.html.twig :
{%
set classes = [
'bef-links',
]
%}
<input type="hidden" name="{{ element["#name"] }}" value="{{ element["#value"] }}" />
<div{{ attributes.addClass(classes) }}>
{% set current_nesting_level = 0 %}
{% for child in children %}
{% set item_attribute = create_attribute() %}
{% set item = attribute(element, child) %}
{% if child in selected %}
{% set item_attribute = item_attribute.addClass(['active']) %}
{% endif %}
<a href="{{ item['#url'] }}" {{ item_attribute.addClass(['btn', 'btn-outline-secondary' , 'btn-sm']) }}>
{{ item['#title'] }}
</a>
{% endfor %}
</div>
But with the 8.4.x it seem that {% if child in selected %} has no effect.
This is how I tried to adapt the template
{%
set classes = [
'bef-links',
is_nested ? 'bef-nested'
]
%}
{% set is_nested = true %}
<div{{ attributes.addClass(classes) }}>
{% set current_nesting_level = 0 %}
{% for child in children %}
{% set item = attribute(element, child) %}
{% if item in selected %}
{% set new_nesting_level = attribute(depth, child) %}
{% set item = item|merge({'#attributes': {'class': ['active', 'btn', 'btn-outline-secondary' , 'btn-sm']}}) %}
{% else %}
{% set item = item|merge({'#attributes': {'class': ['btn', 'btn-outline-secondary' , 'btn-sm']}}) %}
{% endif %}
{% set new_nesting_level = attribute(depth, child) %}
{{ item }}
{% set current_nesting_level = new_nesting_level %}
{% endfor %}
</div>