Add accessibility attributes to sortable table headers. (#3647)

This commit is contained in:
Pieter Frenssen
2022-11-23 12:36:57 +02:00
committed by GitHub
parent 52f5e5640e
commit 2aa5eccc7c

View File

@@ -74,6 +74,11 @@
{% if title != 'actions' and not headerOptions.orderBy is same as(false) %}
{% if orderBy == headerOptions.orderBy %}
{% set headerClass = headerClass ~ ' sortable sorting_' ~ (order) %}
{% if order == 'asc' %}
{% set ariaSort = 'ascending' %}
{% else %}
{% set ariaSort = 'descending' %}
{% endif %}
{% else %}
{% set headerClass = headerClass ~ ' sortable sorting' %}
{% endif %}
@@ -84,7 +89,7 @@
{% elseif title is not empty and title != 'actions' %}
{% set headerTitle = (translationPrefix ~ title)|trans({}, translationDomain) %}
{% endif %}
<th data-field="{{ title }}" {% if not headerOptions.orderBy is same as(false) %}data-order="{{ headerOptions.orderBy }}" {% endif %}class="{{ headerClass }}">
<th data-field="{{ title }}" {% if not headerOptions.orderBy is same as(false) %}data-order="{{ headerOptions.orderBy }}" role="button" {% endif %}{% if ariaSort is defined %}aria-sort="{{ ariaSort }}" {% endif %}class="{{ headerClass }}">
{% if headerOptions.html_before is defined %}
{{ headerOptions.html_before|raw }}
{% endif %}