MDL-86490 output: Mark icon in action_icon as decorative

This commit is contained in:
Jun Pataleta
2025-08-28 18:34:11 +08:00
parent 0ec57fc3f2
commit df486967e4
+14 -8
View File
@@ -1661,14 +1661,20 @@ class core_renderer extends renderer_base {
$attributes['class'] = 'action-icon';
}
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 = $pixicon->attributes['alt'];
// Set the icon as a decorative image. The accessible label should be within the link itself and not the icon.
$pixicon->attributes['alt'] = '';
$pixicon->attributes['title'] = '';
$pixicon->attributes['aria-hidden'] = 'true';
$attributes['class'] .= ' mx-1 p-1';
if (!$linktext) {
// Set a title attribute on the link for sighted users if no text is shown.
$attributes['title'] = $text;
// Style the icon button for increased target area.
$attributes['class'] .= ' btn btn-link icon-no-margin';
// Make the action text only available to screen readers.
$attributes['aria-label'] = $text;
$text = '';
}