MDL-70829 core: Set the icon of action icons as a decorative image

* When text is rendered for the action icon, set the icon as a
decorative image by setting empty alt and title attributes and adding
the aria-hidden attribute as well. Otherwise, assistive technologies
will read the action name twice.
This commit is contained in:
Jun Pataleta
2024-03-19 00:04:11 +08:00
parent f17285be09
commit 371f59c20b
+7 -2
View File
@@ -2117,14 +2117,19 @@ class core_renderer extends renderer_base {
$attributes['class'] = 'action-icon';
}
$icon = $this->render($pixicon);
if ($linktext) {
$text = $pixicon->attributes['alt'];
// Set the icon as a decorative image if we're displaying the action text.
// Otherwise, the action name will be read twice by assistive technologies.
$pixicon->attributes['alt'] = '';
$pixicon->attributes['title'] = '';
$pixicon->attributes['aria-hidden'] = 'true';
} else {
$text = '';
}
$icon = $this->render($pixicon);
return $this->action_link($url, $text.$icon, $action, $attributes);
}