The facets-item-list.html.twig template documents the attributes variable, but overwrites it:

 * - attributes: HTML attributes to be applied to the list.

SNIP

{% if context.list_style %}
  {%- set attributes = attributes.addClass('item-list__' ~ context.list_style).addClass('cake') %}
{% endif %}

SNIP

  {%- if items -%}
    <{{ list_type }}{{ attributes }}>

Furthermore, if using, say, the dropdown widget, then the list HTML element will get replaced, and AFAIK any attributes there won't be in the resulting HTML output.

Comments

joachim created an issue. See original summary.

dragos-dumi’s picture

dragos-dumi’s picture

Assigned: Unassigned » dragos-dumi

That overwrite seems fine for me. It just adds some new classes for list style, but the attributes that are already doesn't get lost.
I will attach a patch for preserving attributes of list to when gets replaced by select.

dragos-dumi’s picture

Status: Active » Needs review
StatusFileSize
new970 bytes
dragos-dumi’s picture

StatusFileSize
new1.5 KB
new567 bytes
borisson_’s picture

Status: Needs review » Fixed

  • borisson_ committed 03e2f4a on 8.x-1.x authored by dragos-dumi
    Issue #2896166 by dragos-dumi: facets-item-list.html.twig overrides...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.