Skip to content

Commit 39a4fe5

Browse files
committed
ELA-1432: accessibility, set aria-hidden and focusable=false on icon
Apply attributes when an icon is defined, no visible label is present, and an aria-label is provided.
1 parent 712b4e7 commit 39a4fe5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

templates/patterns/button/pattern-button.html.twig

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,19 @@
44
* Button pattern.
55
*/
66
#}
7-
{% if icon %}
8-
{% set icon_data = icon is iterable ? icon : { name: icon } %}
9-
{% set _icon = { path: bcl_icon_path }|merge(icon_data) %}
7+
{% if icon %}
8+
{% set _icon = {
9+
path: bcl_icon_path,
10+
name: icon,
11+
attributes: create_attribute()
12+
} %}
13+
{% if label is empty and attributes['aria-label'] is not empty %}
14+
{% set _icon = _icon|merge({
15+
attributes: _icon.attributes
16+
.setAttribute('aria-hidden', 'true')
17+
.setAttribute('focusable', 'false')
18+
}) %}
19+
{% endif %}
1020
{% endif %}
1121
{% include '@oe-bcl/button' with {
1222
'label': label,

0 commit comments

Comments
 (0)